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