Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits *x* and *y*. For example, if *x* = 4, and *y* = 7, then numbers 47, 744, 4 are lucky.

Let's call a positive integer *a* undoubtedly lucky, if there are such digits *x* and *y* (0 ≤ *x*, *y* ≤ 9), that the decimal representation of number *a* (without leading zeroes) contains only digits *x* and *y*.

Polycarpus has integer *n*. He wants to know how many positive integers that do not exceed *n*, are undoubtedly lucky. Help him, count this number.
The first line contains a single integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">9</sup>) — Polycarpus's number.
# if num>x stop , if num is repeated dont count , 
# import sys
# sys.setrecursionlimit(10000)
def undounted(num):
    global i,b,x,z,lst
    if num>x:
        return
    else:
        if num not in lst:
            lst.append(num)
            z+=1
    return undounted(num*10+i),undounted(num*10+b)
def zero(num):
    global i,b,lst,z
    num = int(num)
    if num>x:
        return
    else:
        if num not in lst:
            lst.append(num)
            z+=1
    return zero(str(num)+str(b)),zero(str(num)+'0')
x = int(input())
z = 0
lst = []
for i in range(1,10):
    for b in range(1,10):
        undounted(b)
        if i==1:
            zero(b)
print(z)