n = input().zfill(18)
if len(n) == 19:
    n = "9" * 18
S = n[:9]
T = n[9:]
S = int(S)
T = int(T)
if T >= S:
    n = S
else:
    n = S - 1

ans = 0
x = 1
while 1:
    br = False
    for i in range(x, 10 * x):
        i = str(i)
        z = i + i[::-1]
        if int(z) <= n:
            ans += 1
        else:
            br = True
        for j in range(10):
            z = i + str(j) + i[::-1]
            if int(z) <= n:
                ans += 1
            else:
                br = True
    x *= 10
    if br:
        break

print(ans)