atcoder#ABC283C. [ABC283C] Cash Register
[ABC283C] Cash Register
Score : points
Problem Statement
Takahashi is a cashier.
There is a cash register with keys: 00
, 0
, 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, and 9
.
The cash register initially displays .
Whenever he types the key 00
, the displayed number is multiplied by ;
whenever he types one of the others, the displayed number is multiplied by , and then added by the number written on the key.
Takahashi wants the cash register to display an integer . At least how many keystrokes are required to make it display ?
Constraints
- is an integer.
Input
The input is given from Standard Input in the following format:
Output
Print the answer in a line.
40004
4
For example, the following four keystrokes make the cash register display . Initially, the cash register displays .
- Type the key
4
. It now displays . - Type the key
00
. It now displays . - Type the key
0
. It now displays . - Type the key
4
. It now displays .
He cannot make it display with three or fewer keystrokes, so should be printed.
1355506027
10
10888869450418352160768000001
27
Note that may not fit into a - integer type.