#include using namespace std; using ll = long long int; int main() { ll n, d; cin >> n >> d; vector A; multiset B; //A(:=xx+yy),B(:=ww-zz+D)の取り得る値を列挙 for (ll x = 1; x <= n; ++x) { for (ll y = 1; y <= n; ++y) { A.push_back(x * x + y * y); } } for (ll x = 1; x <= n; ++x) { for (ll y = 1; y <= n; ++y) { B.insert(x * x - y * y + d); } } int cnt = 0; for (auto a : A) { cnt += B.count(a); } cout << cnt << endl; return 0; }