#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; #define all(x) x.begin(),x.end() const ll mod = 1e9+7; const ll INF = 1e9; const ll MAXN = 1e9; int main() { ll n,d; cin>>n>>d; vector cnt_xy(2*n*n+1,0),cnt_wz(2*n*n+1,0); for(ll x = 1; x <= n; x++){ for(ll y = 1; y <= n; y++){ ll res = x*x + y*y; cnt_xy[res]++; } } for(ll w = 1; w <= n; w++){ for(ll z = 1; z <= n; z++){ ll res = w*w-z*z+d; if(res>=1 && res <= 2*n*n) cnt_wz[res]++; } } ll ans=0; for(int i = 1; i <= 2*n*n; i++){ ans += cnt_xy[i]*cnt_wz[i]; } cout << ans << endl; return 0; }