Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

In front of jsumabat lies a red button, a blue button, and a number. When jsumabat clicks the red button, the number in front of him is subtracted by 1. When he clicks the blue button, the number in front of him is multiplied by 2. The number will initially start as N.

jsumabat wants to get the number M. What is the minimum number of times jsumabat has to click either buttons to get M from N?

Input Specification

The first and only line of input will contain 2 integers, N and M (1 \le N, M \le 10^4).

Output Specification

Print a single number - the minimum number of times jsumabat needs to push the buttons in order to get M from N.

Sample Input 1

4 6

Sample Output 1

2

Explanation: Push the red button once, then the blue button once.

Sample Input 2

10 1

Sample Output 2

9

Explanation: Click the red button 9 times.


Comments

There are no comments at the moment.