Triangular King
Very easy
Execution time limit is 0.5 seconds
Runtime memory usage limit is 256 megabytes
After the lumpen-proletarian rebellion staged a pawn on the chessboard, White's king was forced to seek political asylum in another country. After much wandering, he settled in the country, somehow reminding him of his homeland. Here is a map of this country:
Here he began to wander across the field, moving from one cell to another, but only if they have a common side. One day, finding lodging on field A, he thought, for a minimum number of moves he can get to the field B. Help to His Majesty The White King In Exile to solve this not chess puzzle.
Input
In the input file contains two positive integers A and B, not exceeding 10^6.
Output
The output file output the minimum number of moves needed to King-wanderer, to reach the field B.
Examples
Input #1
Answer #1
Submissions 189
Acceptance rate 22%