n=int(input())
res=[]
for i in range(n+1):
    if str(i**2)[len(str(i**2))-len(str(i)):]==str(i):
        res.append(i)
print(len(res))