def solve(): n,d=map(int,input().split()) MAX=8000001 cnt=[0]*MAX cnt[d]=2*n for i in range(1,n+1) : for j in range(i+1,n+1) : cnt[j*j-i*i+d]+=2 if i*i-j*j+d>0 : cnt[i*i-j*j+d]+=2 ans=0 for i in range(1,n+1) : for j in range(i+1,n+1) : if(i*i+j*j<=5000000): ans+=cnt[i*i+j*j] else : j=n+1 for i in range(1,n+1) : ans+=cnt[2*i*i]//2 print(ans) solve()