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