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

1117. Hierarchy

Time limit: 1.0 second
Memory limit: 64 MB
Problem illustration
During long years of work in SKB Kontur a certain hierarchy of employees has been developed. Each person except ordinary employees has exactly two direct subordinates and not more than one direct superior. There is no subordinate of ordinary employees (see figure).
Each employee has his own number. Of course, different employees have different numbers. It's known as well that either an employee has the maximal number or there is another employee whose number is greater by one. Similarly, either an employee has a number "1" or there is another employee whose number is less by one. The number of intermediate levels of employees between an arbitrary employee who has subordinates (an ordinary employee) and the employee who has no superiors (the main superior) is the same for all ordinary employees.
The things have come round so that each employee who has subordinates has got a number greater than the number of one of his subordinates and less than the number of the other. Moreover, if his number is greater than his superior's then the numbers of his subordinates are also greater than the number of his superior. And conversely, if his number is less, then his subordinates' numbers are less too.
A special system of intracorporate message exchange has been worked out. A message from an employee with the number i can be addressed directly only to the employees i-1 and i+1. Moreover, this is done the same day (it takes 0 days to do that) if the employees are direct superior and subordinate. Otherwise, the message delivery takes an amount of days that is equal to the number of intermediate employees between the sender and recipient. For example, a message from the employee 2 to the employee 4 is being delivered as follows. The employee 2 sends the message to the employee 3, and the employee 3 addresses it to the employee 4. This process takes one day because the first step (2->3) takes 0 days, and the second one (3->4) takes 1 day.

Input

The only line contains two positive integers: the number of an employee who sends a message and the number of the recipient. Each of the numbers doesn't exceed 231−1.

Output

You should output the only number — the number of days necessary to deliver the message.

Sample

inputoutput
1 5
2
Problem Author: Alexander Somov
Problem Source: USU Open Collegiate Programming Contest October'2001 Junior Session