Sorty Numbers
View as PDFAny non-negative integer (including ) is sorty if its digits are in a strictly increasing order,
from most significant to least significant. In other words, for any digit, any other digit which
has lower significance than it must have strictly greater value.
For example, is sorty, since
and
.
is not sorty, since
.
is also not sorty, since the digits must be strictly ascending, meaning they cannot be the
same.
Given some integer , output the number of sorty numbers in the range
.
Input
A single integer is given, .
Output
Output a single integer, which is the number of sorty numbers less than or equal to .
Constraints
Example 1
Input
12
Output
11
Explanation
The first sorty numbers are:
and
.
Example 2
Input
244
Output
80
Example 3
Input
214
Output
74
Comments