409530: GYM103625 D Gold Coins Game

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Gold Coins Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Jack Sparrow and other pirates on The Black Pearl have been at sea for 2 months now. In order to pass the time, they have started a tournament for the gold coin game that Jack Sparrow created. The game starts with $$$x$$$ coins on the table and the goal of the game is to end up with $$$y$$$ coins on the table. There are two possible moves that a player can take. They can either remove one coin from the table or triple the number of coins on the table. Jack has decided that he wants to play in the tournament: since he created the game, he always knows the most optimal move to take and finishes the game in the least number of moves possible. Given a value for $$$x$$$ and $$$y$$$, determine the number of moves it will take Jack to complete the game.

Input

There will be one line of input. The first integer represents $$$x$$$ $$$(1 \leq x \leq 20)$$$ and the second integer represents $$$y$$$ $$$(1 \leq y \leq 30)$$$.

Output

Output the number of moves it will take Jack to complete the game.

ExamplesInput
5 5
Output
0
Input
10 24
Output
3
Note

For the first test case, since $$$x$$$ is already equal to $$$y$$$, Jack needs 0 moves to complete the game. For the second test case, Jack can remove 2 coins and then triple the number of coins for a total of 3 moves.

加入题单

算法标签: