def x(n):r=range(-n,n+1);print sum(a*a+b*b==n for a in r for b in r)
x(0)