Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at some point the number stops being positive, the device breaks down. The display can show arbitrarily large numbers. Initially, the display shows number *n*.

Bob wants to get number *m* on the display. What minimum number of clicks he has to make in order to achieve this result?
The first and the only line of the input contains two distinct integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">4</sup>), separated by a space .
import math


nums = list(map(int, input().split(" ")))
a = nums[0] # the number we have displayed
b = nums[1] # the target number
bcopy = b # a copy of the target number that we will not modify
count = 0 #count of operations (buttons pressed)


'''
if the target is greater than the value we have we will try to find a base that satisfies:

the number is less than the value we have (since we don't have an add button and multiplying will just give us a number that is a factor of our number)
the number is the closest greater number to the target value

the strategy is as follows:
find the base by recursive division by tow
try to get the value you have to the base
'''
while(b > a):
    b = math.ceil(b/2) #in case the result is odd we can reach the closest even then substract one e. g. 25 -> 24
    count+=1 #the count in this case is the base that will be using to generate the target number b

#print(b*math.pow(2, count))
reachPoint = b*2**count #we will see how close the count can get and we will reach an upper bound

count+=reachPoint-bcopy # now we will substract that upper bound from the target value equivilent to -1 operations

if(count!=0 and a > 2): # if we have already went through the previous loop
    count+= bcopy%2 # then we check whether we need to add an extra substract operation in case the number was odd


count+= a - b #

#if b%2!=0 and count==0:
#    count+=1

print(count)


'''
3
5
10

'''