def f1(n):
    return str(n ** 2).endswith(str(n))

print(sum([f1(n) for n in range(int(input()) + 1)]))