Harry has a strange number machine that has two buttons. The machine has a number $$$x$$$ on its screen. If button A is pressed, the number on the screen changes to $$$3x+2$$$. If button B is pressed, the number on the screen changes to $$$x+1$$$. The initial number on the machine is 1, and Harry wants to change the number to $$$n$$$. Harry is lazy so he wants to press the least number of buttons possible.
What is the minimum number of button presses Harry has to make in order to obtain the number $$$n$$$?
The first line contains the integer $$$n$$$ ($$$1\le n\le 10^{18}$$$).
Output a single integer denoting the minimum number of button presses.
5
1
20
3
| Name |
|---|


