The number of ones#44

The number of ones

1 second
128 megabytes
Easy

In an arithmetic expression, only the number , the operations of addition and multiplication, and parentheses are allowed. What is the minimum number of ones required to represent a given positive integer ?

Input

One integer n~(1 \le n \le 5000).

Output

Print the minimum number of ones used.

Examples

For example, the number can be represented as follows:

7 = (1 + 1) \cdot (1 + 1 + 1) + 1

Example 1

Loading
Loading

Example 17

Loading
Loading