#include using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) int MAX = 5e6; int main(){ int n; cin>>n; int d; cin>>d; vector cnt1(MAX),cnt2(MAX); REP(i,1,n+1)REP(j,1,n+1){ cnt1[i*i+j*j]++; if(i*i-j*j+d>0)cnt2[i*i-j*j+d]++; } long long ans=0; rep(i,MAX)ans+=cnt1[i]*cnt2[i]; cout<