def f(x): if str(x*x)[-len(str(x)):] == str(x): return True return False n = int(input()) c = 0 for i in range(n+1): if f(i): c += 1 print(c)