Moving the king
In American checkers, when a piece reaches the last row, it becomes a king. A king can move diagonally in any direction, but only one square at a time (as illustrated by the arrows in the diagram). Consider a board of size M×N, with a king positioned on a certain square, and no other pieces present (hence, the king cannot capture anything).
Your task is to write a program that calculates the minimum number of moves required for the king to reach a specified target square.
Input
The first line contains two natural numbers M and N, representing the number of vertical and horizontal lines on the board, respectively (1 ≤ M, N ≤ 10^9). The second line contains two natural numbers x_0 and y_0, which are the coordinates (vertical and horizontal line numbers, respectively) of the starting square (1 ≤ x_0 ≤ M, 1 ≤ y_0 ≤ N). The third line provides the coordinates of the target square x_K and y_K in the same format.
Output
Output a single non-negative integer, representing the minimum number of moves required for the king to travel from the starting square to the target square. If the king cannot reach the target square, output -1.