Trio#10250

Trio

1 second
256 megabytes
Very easy

You are given an integer . You can perform the following three types of operations:

  1. Decrease by .

  2. Increase by .

  3. 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 (1 \le n \le 10^{18}).

Output

Output a single integer representing the minimum number of operations required to make the number equal to .

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 5

Loading
Loading

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 1 \le n \le 10^5 will earn of the total points.