You are playing a famous game called \$1\text{D Array BattleGround}\$. In the game, the player can be stationed in any position from \$0\$ to \$10^5\$.
You are a Paratrooper in the game and have the ability to do two types of operation \$-\$
- Advance, which would multiply your position by \$2\$
- Fall-back, which would decrease your current position by \$1\$
Each type of operation requires \$1\$ second.
You are stationed in \$N\$ and want to go to \$M\$ in the minimum time possible, (\$1≤ N, M ≤10^4\$).
Find out the minimum time you need to Get to \$M\$.
Note: After each operation, you must remain in the zone from \$0\$ to \$10^5\$.
Sample
Input : 4 6
Output: 2
Input : 10 1
Output: 9
Input : 1 3
Output: 3
Input : 2 10
Output: 5
Input : 666 6666
Output: 255
Input : 9999 10000
Output: 5000
This is a code-golf challenge so code with lowest bytes wins!