Best Friends

No attempts yetTime limit1sMemory limit128 MB

Problem

Petey and Patty are best friends, and they are locked in a maze. The maze holds an infinite number of circles of the same size, packed into a triangle. The top row holds one circle, the second row holds two, and row rr holds rr circles. Two neighbouring rows sit half a circle apart, so a circle touches the circles beside it in its own row and the two circles under it in the next row. The circles are numbered row by row, from left to right.

         1
       2   3
     4   5   6
   7   8   9  10
11  12  13  14  15

Petey and Patty each stand on a circle, and the two circles are not necessarily different. In one step Petey moves from the circle she stands on to a circle adjacent to it. Two circles are adjacent when they share a point.

Given the numbers of the circles Petey and Patty stand on at the start, find the smallest number of steps Petey needs to reach her friend.

Input

The input holds several test cases. Each line holds two integers aa and bb, the number of the circle Petey stands on and the number of the circle Patty stands on. Neither number is more than 1000010000 (1a,b100001 \le a, b \le 10000).

The last line is 0 0. It marks the end of the input and is not a test case.

Output

For the ii-th test case print one integer on the ii-th line of the output: the smallest number of steps Petey needs to reach her friend.