N = int(input()) L = [str(i) for i in range(1, N//(10**9 + 1) + 1)] ans = 0 for i in L: if i == "".join(list(reversed(i))): ans += 1 print(ans)