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

~/algor $ cat problems/boolean-farzin-yurishi

Queen move

Medium 1000 ms 64 MB 42%
Share

Two different squares of a chessboard $(x_{1}; y_{1})$ and $(x_{2}; y_{2})$ are given. A square is given as $(x; y)$: $x$ is the column number (from left to right), $y$ is the row number (from bottom to top). A queen moves any distance along a column, a row or a diagonal (there are no other pieces in the way). Check whether the statement is true: “the queen on square $(x_{1}; y_{1})$ can move to square $(x_{2}; y_{2})$ in one move”.

A queen's vertical, horizontal and diagonal moves on a chessboard

Input

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

Output

One integer: $1$ if the statement is true, otherwise $0$.

Note

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

Examples

Input #1
4 4 7 7
Output #1
1
Input #2
4 4 6 5
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.