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


def num_to_binary(n):
    ret = []
    while n != 0:
        ret.append(n % 2)
        n //= 2
    return list(reversed(ret))


def solve(start, target):
    '''
    We notice the number we care about is the difference between our target and
    the product of our starting number and the minimum power of two required to
    surpass the target.
    Once we have the difference, we attempt to substract it as soon as possible
    (before the minimum number of `x2` operations) without ever undercutting the
    result (as it would lead to an extra `x2` operation and subsequent many
    extra `-1`).
    '''

    if target <= start:
        p2 = 0
    else:
        p2 = math.ceil(math.log2(target / start))

    cur = start * 2**p2
    # We start our count with the required number of `x2` operations
    count = p2

    excess = cur - target
    # The first part represents the amount of (-1) buttons that couldn't be
    # made soon enough to be minimized further (we can't maximize the impact of
    # the `-1` presses past the number of `x2` presses). The second part is the
    # completely minimized `-1` presses, as they were minimized completely their
    # addition to the count is of the 1s in the number.
    count += (excess >> p2) + sum(num_to_binary(excess % (2**p2)))

    # The complexity is dependant on the arithmetic operations (and probably on
    # the `log` operation), so I refrain from saying anything other than its
    # probably related to the length of the bit representation of the numbers.
    return int(count)


def str_to_list_numbers(s):
    return [int(ds) for ds in s.split()]


def main():
    n, m = str_to_list_numbers(input())
    print(solve(n, m))


if __name__ == '__main__':
    main()

  		   	 		   	  	 	  	 			  	