Task
William has recently built a Water Calculator, which mimics the operation of a computer through water pipes, sinks and siphons. Due to the rudimentary nature of its circuits, the Water Calculator is able to store a single number up to a billion and perform only a handful of atomic operations:
- add or subtract ;
- multiply by ;
- divide by a power of (which divides exactly the stored number).
These few operations are anyway more than sufficient for William's basic mathematical needs.
In this moment, the Water Calculator is holding number . Since William needs to leave his home for a while, it is crucial to empty the calculator in order to avoid malicious rusting! Calculate the minimum number of atomic operations necessary for William to completely empty the calculator.
Input data
The first and only line contains the only integer .
Output data
You need to write a single line with an integer: the minimum number of atomic operations needed to empty the Water Calculator.
Constraints and clarifications
- .
- Operations that would increase the number stored over are not allowed.
# | Points | Constraints |
---|---|---|
1 | 5 | Examples. |
2 | 35 | |
3 | 30 | |
4 | 30 | No additional limitations. |
Example 1
stdin
13
stdout
4
Explanation
In the first sample case, a possible sequence of operations is the following:
Example 2
stdin
81
stdout
2
Explanation
In the second sample case, a single operation brings to and a second one to .