Under construction

Still being built. Things may change

Turn Integer A into K

Interview

Time limit1sMemory limit512 MB

Summary
Given A and K, find the minimum number of operations (add 1 or multiply by 2) needed to turn A into K.
Level

Easy3 of 10

Topics
Greedy, Math
Solved
No attempts yet

Problem

Given positive integers AA and KK, you want to change AA into KK using the following two operations.

  • Operation 1: add 1 to the integer AA.
  • Operation 2: multiply the integer AA by 2.

Find the minimum number of operations needed to turn AA into KK.

Input

The first line contains the positive integers AA and KK, separated by a space.

Output

Print the minimum number of operations needed to turn the positive integer AA into the positive integer KK on the first line.

Constraints

1≤A<K≤1,000,0001 \le A < K \le 1,000,000

Examples3

  1. Example 1

    Input
    5 10
    
    Expected output
    1
    
  2. Example 2

    Input
    7 77
    
    Expected output
    7
    
  3. Example 3

    Input
    1111 997651
    
    Expected output
    850