while True:
try:
n = int(input())
output=0
for i in range(n+1):
sq=i*i
str_sq=str(sq)
str_i =str(i)
num = len(str_i)
if str_i==str_sq[-num:]:
output+=1
print(output)
except:
break