Sorty Numbers


Any non-negative integer (including 00) 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, 167167 is sorty, since 1<61 < 6 and 6<76 < 7.

429429 is not sorty, since 4>24 > 2.

444444 is also not sorty, since the digits must be strictly ascending, meaning they cannot be the same.

Given some integer nn, output the number of sorty numbers in the range [0,n][0, n].

Input

A single integer is given, nn.

Output

Output a single integer, which is the number of sorty numbers less than or equal to nn.

Constraints

  • 0<n1090 < n \le 10^9

Example 1

Input 1
12
Output 1
11
Explanation

The first 1111 sorty numbers are: 0,1,2,3,4,5,6,7,8,90, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 1212.

Example 2

Input 2
244
Output 2
80

Example 3

Input 3
214
Output 3
74

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.