from itertools import count N = 1000000001 n = int(input()) ans = 0 for i in map(str, count(1)): x = int(i + i[::-1]) y = int(i + i[:-1][::-1]) if N * x <= n: ans += 1 if N * y <= n: ans += 1 else: break print(ans)