Calculator
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
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 .
Input
One integer .
Output
Print the minimum number of operations.
Examples
Input #1
Answer #1
Submissions 1K
Acceptance rate 67%