The number of ones#44

The number of ones

1 segundo
128 megabytes
Fácil

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 ?

Entrada

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

Salida

Print the minimum number of ones used.

Ejemplos

For example, the number can be represented as follows:

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

Ejemplo 1

Loading
Loading

Ejemplo 17

Loading
Loading