n = int(input())

count = 0
# 用于取余
mod = 10
for i in range(n+1):
    if mod < i:
        mod *= 10
    if i ** 2 % mod == i:
        count += 1
print(count)