#abc192d. [abc192_d]Base n
[abc192_d]Base n
Problem Statement
Given are a string consisting of 0
through 9
, and an integer .
Let be the greatest digit in .
How many different integers not greater than can be obtained by choosing an integer not less than and seeing as a base- number?
Constraints
- consists of
0
through9
. - The length of is between and (inclusive).
- does not begin with a
0
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
22
10
Sample Output 1
2
The greatest digit in is 2
.
- By seeing as a base- number, we get .
- By seeing as a base- number, we get .
These two values are the only ones that we can obtain and are not greater than .
Sample Input 2
999
1500
Sample Output 2
3
The greatest digit in is 9
.
- By seeing as a base- number, we get .
- By seeing as a base- number, we get .
- By seeing as a base- number, we get .
These three values are the only ones that we can obtain and are not greater than .
Sample Input 3
100000000000000000000000000000000000000000000000000000000000
1000000000000000000
Sample Output 3
1
By seeing as a base- number, we get , which is the only value that we can obtain and are not greater than .