ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1302. Delta-wave

Time limit: 1.0 second
Memory limit: 64 MB
Problem illustration
A triangle field is numbered with successive integers in the way shown on the picture below.
The traveller needs to go from the cell with number m to the cell with number n. The traveller is able to enter the cell through cell edges only, he can not travel from cell to cell through vertices. The number of edges the traveller passes makes the length of the traveller's route.
Write the program to determine the length of the shortest route connecting cells with numbers m and n.

Input

Input contains integers m and n separated with space (1 ≤ m, n ≤ 109).

Output

Output the length of the shortest route.

Sample

inputoutput
6 12 
3
Problem Source: II Collegiate Students Urals Programming Contest. Yekaterinburg, April 3-4, 1998