import sys def solve(): N = int(input()) M = N // (10**9 + 1) ans = 0 k = [0, 9, 9, 90, 90, 900, 900, 9000, 9000, 90000] d = 1 while 10**d <= M: ans += k[d] d += 1 d -= 1 e = 1 while 10**d * e <= M: ans += max(1, k[max(0, d - 2)]) e += 1 e -= 1 if d - 2 >= 0: uni = 10**d + 1 f = 0 while uni*e + f*10 <= M: fs = str(f).zfill(d - 2) if(fs == reversed(fs)): ans += 1 f += 1 print(ans) def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None if __name__ == '__main__': solve()