#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


from functools import lru_cache

# %%
N = int(read())
bound = N // (10 ** 9 + 1)


# %%
@lru_cache(None)
def cnt_palindrome(keta, N, leading_0):
    N = min(10 ** keta - 1, N)
    if keta == 1:
        return N + 1 if leading_0 else N
    if keta == 2:
        return N // 11 + 1 if leading_0 else N // 11
    x = 10 ** (keta - 1) + 1
    low = 0 if leading_0 else 1
    ret = 0
    for i in range(low, 10):
        M = (N - x * i) // 10
        M = min(10 ** (keta - 2) - 1, M)
        if M < 0:
            break
        ret += cnt_palindrome(keta - 2, M, True)
    return ret


# %%
answer = 0
for keta in range(1, 10):
    answer += cnt_palindrome(keta, bound, False)
print(answer)