Minimal penalty#407

Minimal penalty

1 second
128 megabytes
Medium (≈1350)

Initially, you have the number . In one step, it is allowed to either multiply the current number by (penalty ) or add to it (penalty ). Find the minimal total penalty to reach from . If it is not possible, print .

Input

A single integer (1 \le N \le 10^9).

Output

Print the minimal total penalty; print if it is not possible.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Note

In the first example, the following steps are carried out to achieve the minimum penalty:

1\rightarrow +4 \rightarrow+4\rightarrow+4\rightarrow+4\rightarrow+4 = 21