Calculator#10893

Calculator

1 Sekunde
128 Megabyte
Leicht

Ilya's calculator performs two actions: multiplies the current number by three and adds one to it. The calculator now shows the number . Help Ilya to determine the smallest number of operations, after which he will get the number .

Eingabe

One integer n~(10 \le n \le 10^9).

Ausgabe

Print the minimum number of operations.

Beispiele

Beispiel 1

Loading
Loading