Turn Integer A into K
InterviewTime limit1sMemory limit512 MB
Given A and K, find the minimum number of operations (add 1 or multiply by 2) needed to turn A into K.
Problem
Given positive integers and , you want to change into using the following two operations.
- Operation 1: add 1 to the integer .
- Operation 2: multiply the integer by 2.
Find the minimum number of operations needed to turn into .
Input
The first line contains the positive integers and , separated by a space.
Output
Print the minimum number of operations needed to turn the positive integer into the positive integer on the first line.