Олимпиадный тренинг

Задача 27223. The Lost Cow


Задача

Темы:
Farmer John lost his cow Besi and wants to find her.
Luckily, there is only one long road leading through the farm, and the FD knows that Besi is at some point along that road. If we consider this road as a number line, FD is now at x and Besi is now at y (unknown FD). If FD knew where Besie was, he could walk straight towards her by walking a distance of |x−y|. Unfortunately, it's dark now and FD can't see anything. The only way he can find Besie is to walk back and forth until he comes across Besie.
 
Trying to find the best search strategy for the FD, I studied the computer literature and found out that this problem has not yet been solved and is called the "Problem of the Lost Cow".
 
The recommended strategy is to move to position x+1, then reverse direction and move to position x−2, then to position x+4, etc., moving in a "big zigzag", moving twice each time further from its original position than last time. This approach guarantees that in the worst case, he will cover 9 times the direct distance from himself to Besi |x−y|. And this is the smallest number guaranteed in the worst case.
 
The FD wants to test this statement. You are given x and y, calculate the total distance traveled in the search using the "big zig-zag" algorithm described above, traveled until the moment Besi was found.
 
INPUT FORMAT :
 
The single line of input contains two different space-separated integers x and y. Both numbers are in the range 0…1,000.
OUTPUT FORMAT:
 
Print a single line containing the distance traveled by the FD before reaching Besi.

Enter Output
36 9