~/algor $ cat problems/dp-birgacha-amallar
Fewest operations to one
Easy
1000 ms
128 MB
23%
A positive integer $n$ is given. In one operation you may subtract $1$ from the number, divide it by $2$ if it is even, or divide it by $3$ if it is divisible by $3$. What is the smallest number of operations needed to turn $n$ into $1$?
Input
One positive integer $n$.
Output
One integer — the smallest number of operations.
Note
$1 \le n \le 2 * 10^{5}$
Examples
Input #1
10
Output #1
3
Input #2
1
Output #2
0