#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using i64 = int64_t; using i32 = int32_t; template void init_n(vector& v, size_t n, U x) { v = vector(n, x); } template void init_n(vector& v, size_t n) { init_n(v, n, T()); } template void read_n(vector& v, size_t n, size_t o = 0) { v = vector(n+o); for (size_t i=o; i> v[i]; } template void read_n(T a[], size_t n, size_t o = 0) { for (size_t i=o; i> a[i]; } template T gabs(const T& x) { return max(x, -x); } #define abs gabs i64 n, d; int main() { cin >> n >> d; i64 m = 2 * n * n + 1; vector a(m), b(m); for (i64 x = 1; x <= n; ++x) { for (i64 y = 1; y <= n; ++y) { a[x * x + y * y]++; i64 z = x * x - y * y + d; if (0 < z && z <= m) b[z]++; } } i64 ans = 0; for (i64 i = 1; i < m; ++i) { ans += a[i] * b[i]; } cout << ans << '\n'; return 0; }