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