from itertools import count

n = int(input())
ans = 0
for i in map(str, count(1)):
    if int(i + i[::-1]) * 1000000001 <= n:
        ans += 1
    if int(i + i[: len(i) - 1][::-1]) * 1000000001 <= n:
        ans += 1
    else:
        break

print(ans)