#include #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) const int MAX = 7e6; bool quad[MAX]; int main(){ int n; cin>>n; int d; cin>>d; rep(i,n)quad[(i+1)*(i+1)+d]=1; int ans=0; REP(i,1,n+1)REP(j,i,n+1)REP(k,j,n+1){ if(quad[i*i+j*j+k*k]){ if(i==j){ if(j==k)++ans; else ans+=3; } else if(i==k||j==k)ans+=3; else ans+=6; } } cout<