#include using namespace std; using lint = long long; template using V = vector; template using VV = V< V >; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, d; cin >> n >> d; V l(2 * n * n + 1); for (int x = 1; x <= n; ++x) for (int y = 1; y <= n; ++y) { ++l[x * x + y * y]; } V r(d + n * n); for (int w = 1; w <= n; ++w) for (int z = 1; z <= n; ++z) { lint t = d + w * w - z * z; if (t >= 0) ++r[t]; } lint res = 0; for (int i = 0; i < min(l.size(), r.size()); ++i) { res += l[i] * r[i]; } cout << res << '\n'; }