import math
while True:
try:
n = int(input())
count = 0
for i in range(1, n+1):
d = int(math.log10(i))+1
if i*i % 10**d == i:
count += 1
print(count+1)
except:
break