#include #include using namespace std; using namespace atcoder; using ll=int; using ld=long double; ld pie=3.141592653589793; ll inf=444444444; ll mod=1000000007; int main(){ ll n,d; cin >> n >> d; vectormemo(n*n+n*n+2,0); for (ll i = 1; i <=n; i++) { for (ll j = 1; j <=n; j++) { memo[i*i+j*j]+=1; } } vectormemo2(n*n+n*n+2+d,0); for (ll i = 1; i <=n; i++) { for (ll j = 1; j <=n; j++) { if (i*i-j*j+d<=0) { continue; } memo2[i*i-j*j+d]+=1; } } ll ans=0; for (ll i = 1; i < memo.size(); i++) { ans+=memo[i]*memo2[i]; } cout << ans << endl; }