#P9204. 不死「火鸟 −凤翼天翔−」
不死「火鸟 −凤翼天翔−」
Background
Fujiwara no Mokou, who has gained the power of “immortality”, also obtained the ability to control flames, and became the incarnation of a firebird.
Are a firebird and a phoenix the same kind of creature?
Problem Description
Mokou can control a firebird. The firebird can be seen as a piece placed on an infinitely large chessboard, with located at . moves by the following rules:
- On odd-numbered moves, can only move one square to the upper-right or lower-left, as shown by the red arrows in the figure.
- On even-numbered moves, can only move one square to the lower-right or upper-left, as shown by the blue arrows in the figure.

Because the board is infinite, and may be negative.
In each step, cannot stay in place. Now we need to move to position with coordinates . What is the minimum number of steps? In particular, if no such plan exists, output .
The figure below shows the case and . One optimal plan is marked in the figure and requires steps. Red segments represent odd-numbered moves, and blue segments represent even-numbered moves.

Input Format
The input consists of one line with four integers , describing the coordinates of and .
Output Format
Output one line with one integer. If there exists a move sequence from to , output the minimum number of steps; otherwise output .
2 7 5 2
9
2 2 3 2
-1
0 0 1000000000 1000000000
2000000000
Hint
Constraints and Notes
For all testdata, it is guaranteed that .
Translated by ChatGPT 5