n = int(input())
num = 0
for i in range(0, n + 1):
    x = i * i
    y = str(x)[::-1]
    z = str(i)[::-1]
    if y.startswith(z):
        num += 1
print(num)