while True:
try:
a = int(input())
res = 0
for i in range(a+1):
b =str(i * i)
if b[len(b)-len(str(i)):len(b)] == str(i):#注意只有字符串i才能取长度
res+=1
print(res)
except:
break