Buttons
View as PDFIn front of lies a red button, a blue button, and a number. When 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 .
wants to get the number . What is the minimum number of times has to click either buttons to get
from
?
Input Specification
The first and only line of input will contain 2 integers, and
(
.
Output Specification
Print a single number - the minimum number of times needs to push the buttons in order to get from
.
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