Time limit
2s
Memory limit
128 MB
Subin is playing hide-and-seek with his younger sibling.
Subin is currently at point N, and the sibling is at point K. Both positions are integers satisfying 0 <= N, K <= 100000.
In one second, Subin can either walk or teleport. If he is at position X, walking moves him to X-1 or X+1 after one second, while teleporting moves him to 2*X after one second.
Find the minimum time needed for Subin to reach the sibling.
The first line contains Subin's position N and the sibling's position K, separated by a space. Both values are integers.
Print the minimum number of seconds needed for Subin to reach the sibling.
When N=5 and K=17, Subin can arrive in 4 seconds by moving 5 -> 10 -> 9 -> 18 -> 17.