AKVDHN02 - Butters and Magical Numbers 375 Points

no tags 

Butters came to know that magical numbers are those numbers whose decimal representation (without leading zeros) contains only the magical digits x and y. For example, if x = 5 and y = 3, then the numbers 53, 5, 335 are magical.

A positive integer Z is called magical number if there are such digits x and y (0 <= x, y <= 9), that the decimal representation of number Z (without leading zeros) contains only digits x and y.

Butters has integer N. He wants to know how many positive integers are there that do not exceed N and are magical.

Input

The only line of input will contain an integer N.

Output

Print a single integer that says, how many positive integers are there that do not exceed n and are magical.

Constraints

1 <= N <= 10^9

Example

Input:
10

Output:
10
Input:
123

Output:
113

Note:

In the second example case, the numbers 102, 103, 104, 105, 106, 107, 108, 109, 120 and 123 are not magical.



Added by:Ankit Kumar Vats
Date:2013-08-15
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Self