Score : $400$ points
Given are a string $X$ consisting of 0
through 9
, and an integer $M$.
Let $d$ be the greatest digit in $X$.
How many different integers not greater than $M$ can be obtained by choosing an integer $n$ not less than $d+1$ and seeing $X$ as a base-$n$ number?
0
through 9
.0
.Input is given from Standard Input in the following format:
$X$ $M$
Print the answer.
22 10
2
The greatest digit in $X$ is 2
.
These two values are the only ones that we can obtain and are not greater than $10$.
999 1500
3
The greatest digit in $X$ is 9
.
These three values are the only ones that we can obtain and are not greater than $1500$.
100000000000000000000000000000000000000000000000000000000000 1000000000000000000
1
By seeing $X$ as a base-$2$ number, we get $576460752303423488$, which is the only value that we can obtain and are not greater than $1000000000000000000$.