import sys input=lambda: sys.stdin.readline().rstrip() n,d=map(int,input().split()) import collections D=collections.defaultdict(int) for i in range(1,n+1): D[2*(i**2)]+=1 for j in range(i+1,n+1): D[i**2+j**2]+=2 ans=0 for i in range(1,n+1): for j in range(1,n+1): a=j**2-i**2+d if a>1: ans+=D[j**2-i**2+d] print(ans)