def kaibun(y): x = len(str(y)) flag = 0 X = [9,9] i = 2 while x > i: if i % 2 == 0: X.append(X[i - 1] * 10) else: X.append(X[i - 1]) i = i + 1 a = sum(X[:x - 1]) for j in range(1, x // 2 + 1): if j == 1: a = a + (int(str(y)[j - 1]) - 1) * X[x - 2 * j + 1]//9 else: a = a + (int(str(y)[j - 1])) * X[x - 2 * j + 1] // 9 if str(y)[:x//2][::-1] and str(y)[x//2 + 1:] and int(str(y)[:x//2][::-1]) <= int(str(y)[x//2:]) and x % 2 == 0: a = a + 1 flag = 1 elif x % 2 == 1: a = a + int(str(y)[x//2]) if str(y)[:x//2][::-1] and str(y)[x//2 + 1:] and int(str(y)[:x//2][::-1]) <= int(str(y)[x//2 + 1:]): a = a + 1 flag = 1 if x == 1: return y,flag return a,flag # X[i] は i 桁の自然数のうち回文となるものの個数 n = input() if len(n) < 10: print(0) else: ni = n[:-9] k = int(ni) answer,flag = kaibun(k) if len(n) == 10 and int(n) % 10**9 < int(n[0]): answer = answer - 1 if flag == 1 and int(ni[::-1]) > int(n[-9:]): answer = answer - 1 print(answer)