#R1019. [KBC002C] Sequence 4
[KBC002C] Sequence 4
Problem Description
Given a sequence of integers, you need to add digits at the end of the integers in order to make the sequence strictly increasing.
Adding digit () at the end of a number can be represented as .
Find the minimum number of digits to be added.
Constraints
For of the test cases:
- .
- .
- Score: pts.
For the remaining of the test cases:
- .
- All the numbers in are equal.
- Score: pts.
Input
The input is given in the following format from the standard input:
Output
Output the minimum number of digits to be added.
Sample Input
4
20
1
45
132
Sample Output
4
Explanation
After adding digits, the sequence becomes .
Note that this is not the only possible solution.