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