import itertools,fractions
from collections import defaultdict
N=1000000
g=defaultdict(set)
u=2
while u*u <= N:
v=1
while v < u and (u*u+v*v) <= N:
if fractions.gcd(u,v)==1:
a=2*u*v
b=u*u-v*v
c=u*u+v*v
k=1
while k*c < N:
g[k*a].add(k*b)
g[k*b].add(k*a)
k+=1
v+=1
u+=1
print sum((a*b)%(a+b)==0 for i in range(1,N) for a,b in itertools.combinations(g[i],2))