Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/if-fil-necha-yurishda

Bishop moves

Medium 1000 ms 64 MB 45%
Share

Two different squares of a chessboard are given: a bishop stands on $(x_{1}; y_{1})$. Determine the smallest number of moves the bishop needs to reach $(x_{2}; y_{2})$. If it cannot get there, print $-1$.

A bishop's moves to the given square on a chessboard

Input

One line with four integers: $x_{1}$, $y_{1}$, $x_{2}$ and $y_{2}$.

Output

One integer: the smallest number of moves, or $-1$.

Note

$1 \le x_{1}, y_{1}, x_{2}, y_{2} \le 8$
The squares are different.

Examples

Input #1
3 1 6 4
Output #1
1
Input #2
3 1 3 5
Output #2
2

Sign in to submit a solution

Signing up is free and takes a minute.