#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; //const long long MOD = 1000000007LL; const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll cnt[10000000]; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll N, D; scanf("%lld %lld", &N, &D); vector t; for (ll i = 1; i <= N; i++) { for (ll j = 1; j <= N; j++) { cnt[i*i + j * j]++; } } sort(t.begin(), t.end()); ll res = 0; for (ll i = 1; i <= N; i++) { for (ll j = 1; j <= N; j++) { ll tmp = j * j - i * i + D; if (tmp < 0) continue; res += cnt[tmp]; } } cout << res << endl; return 0; }