Time

12:38:40
23 May 2012
Version for print

The number of units

   In arithmetic expression you are allowed to use the number 1, operations of addition, multiplication and parenthesis. What is the minimum number of ones you need to obtain the positive integer n?


Specifications

   Input

   One number n (1n5000).

   Output

   The required number of ones.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 6.25
Complexity: 44% 222/395
Classes: Dynamic programming

Example

Example input

7

Example output

6


← Competitors’ quantity of olimpia Problems The Fuel →