Trio
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 256 megabytes
You are given an integer . You can perform the following three types of operations:
Decrease by .
Increase by .
If is divisible by , divide by .
Determine the minimum number of operations needed to transform the number into .
Input
The input consists of a single integer ().
Output
Output a single integer representing the minimum number of operations required to make the number equal to .
Examples
Input #1
Answer #1
Input #2
Answer #2
Input #5
Answer #5
Note
In the first example, you can divide by once to reach .
In the second example, you can decrease by twice, and then divide by .
Scoring
Solutions that correctly handle the constraints will earn of the total points.
Submissions 2K
Acceptance rate 28%