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