import math n = int(input()) assert n <= 10**7 ans = 0 sqrt = int(n ** .5) + 1 for b in range(1, sqrt): for a in range(b + 1, sqrt): p = a**2 + b**2 if p%4 != 1: continue if math.gcd(a, b) != 1: continue q = a**2 - b**2 r = 2 * a * b ans += n // (p + q + r) print(ans)