def check(n): ok = 1 s = str(n) L = len(s) for i in range(L): if s[i] != s[L-1-i]: ok = 0 return ok def main(): A = 10**9+1 n = int(input()) now = A ct = 0 while now < n: ct += check(now) now += A return ct if __name__ == '__main__': print(main())