while 1: try: a = int(input()) n = 0 for i in range(a+1): if str(i**2).endswith(str(i)): n+=1 print(n) except: break