Hide and Seek 3

Given start N and target K, find the minimum number of one-step moves when moving X to X-1 or X+1 costs one second and moving X to 2X costs nothing.

Medium5BFSGraphShortest pathNo attempts yetTime limit2sMemory limit512 MB

Problem

Subin is playing hide and seek with his younger brother. Subin is at point NN and his brother is at point KK. Subin can walk or teleport.

When Subin is at point XX and walks, he arrives at X1X-1 or X+1X+1 one second later. When he teleports, he arrives at 2X2X with no time passing. A position after a move must be at least 0, and there is no upper limit.

Given both positions, write a program that computes the earliest time, in seconds, at which Subin reaches his brother.

Input

The first line contains Subin's position NN and his brother's position KK, separated by a single space. Both are integers with 0N100,0000 \le N \le 100{,}000 and 0K100,0000 \le K \le 100{,}000.

Output

Print on the first line the earliest time in seconds at which Subin reaches his brother.

Hint

For N=5N = 5 and K=17K = 17, moving 5 → 10 → 9 → 18 → 17 reaches the brother in 2 seconds.