import sys

data=int(sys.stdin.readline())

def se(n):
    length=len(str(n))
    if str(int(n*n))[-1*length:]==str(n):
        return True
    else:
        return False


count=0
for i in range(0,data+1):
    if se(i):
        count=count+1

print(count)