N = int(input()) m = 10**9+1 n = N // m ans = 0 for i in range(1,n+1): if str(i) == str(i)[::-1]: ans += 1 print(ans)