409530: GYM103625 D Gold Coins Game
Description
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.
InputThere 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)$$$.
OutputOutput the number of moves it will take Jack to complete the game.
ExamplesInput5 5Output
0Input
10 24Output
3Note
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.