Starting from $N$, you may repeatedly (a) divide by $3$ if divisible, (b) divide by $2$ if divisible, or (c) subtract $1$. Print the minimum number of operations to reach $1$.
Input
One integer $N$ ($1 \le N \le 10^6$).
Output
Print the minimum number of operations.
Example 1
Input
2
Output
1
Example 2
Input
10
Output
3
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.