Problems
Triangular King
Triangular King
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 data
In the input file contains two positive integers A and B, not exceeding 10^6.
Output data
The output file output the minimum number of moves needed to King-wanderer, to reach the field B.
Examples
Input example #1
2 16
Output example #1
6