n = int(input()) a = 1 ans = 0 while(True): m = a* (1000000000 + 1) a += 1 if m > n: print(ans) break if list(str(m))==list(str(m))[::-1]: ans += 1