#include using namespace std; int main() { ios::sync_with_stdio(false); int N, D; { cin >> N >> D; } vector s; { for (int x = 1; x <= N; ++x) { for (int y = 1; y <= N; ++y) { s.push_back(x * x + y * y); } } sort(s.begin(), s.end()); } vector pc(2000 * 2000 * 2 + 1); { for (int v : s) pc[v] += 1; for (int i = 1; i < pc.size(); ++i) pc[i] += pc[i - 1]; } int64_t res = 0; { for (int w = 1; w <= N; ++w) { for (int z = 1; z <= N; ++z) { int t = w * w - z * z + D; if (t <= 0 || pc.size() <= t) continue; res += pc[t] - pc[t - 1]; } } } cout << res << endl; }