Its new year time so is the time for celebration. Mathematician Ronald discovered some numbers following a property and he calls them new numbers. A new number is a number such that all the permutations of that number are greater (old) than that lexicographically . For example 12 is a new number as there is only one another permutation 21 which is greater than that. Some other new numbers are 19 , 157 . Given a N as input , you have to count total new natural numbers not greater than N.
Constraints
1≤N≤1018
Input
First line contains N as input.
Output
Print count of total numbers satisfying the given property
*Note that any number which has no distinct pemutation except itself then it is counted *
Except 10 all numbers which are less than or equal to 15 satisfy the given property