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