def s(n,d): cnt=[0]*8000001 ans=0 xyz=[i*i for i in range(1,n+1)] for I in [i-j+d for i in xyz for j in xyz if i-j+d>0]: cnt[I]+=1 for x in [i+j for i in xyz for j in xyz]: ans+=cnt[x] return ans n,d=map(int,input().split()) print(s(n,d))