#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using i64 = long long; using ui64 = unsigned long long; using P = pair; constexpr int INF = (1 << 30); constexpr std::int64_t INF64 = (1LL << 60); constexpr int MOD = 1e9 + 7; //constexpr std::int64_t MOD64 = 1e11 + 3; int dx[] = { -1, 0, 1, 0 }; int dy[] = { 0, 1, 0, -1 }; template static inline std::vector makeNdVector(T n, U val) noexcept { static_assert(std::is_integral::value, "[makeNdVector] 1st argument must be an integer type"); return std::vector(std::forward(n), std::forward(val)); } template static inline decltype(auto) makeNdVector(T n, Args... args) noexcept { static_assert(std::is_integral::value, "[makeNdVector] 1st argument must be an integer type"); return std::vector(args)...))>(std::forward(n), makeNdVector(std::forward(args)...)); } template void print(vector vec) { for (auto &e : vec) cout << e << " "; cout << endl; } void YES(bool f) { cout << (f ? "YES" : "NO") << endl; } void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; } void yes(bool f) { cout << (f ? "yes" : "no") << endl; } template T gcd(T x, T y) { if (x == 0 || y == 0) return 0; T r; while ((r = x % y) != 0) { x = y; y = r; } return y; } template T lcm(T x, T y) { if (x == 0 || y == 0) return 0; return (x / gcd(x, y) * y); } int next_combination(int sub) { int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } std::uint64_t combination(int n, int r) { if (n < 0 || r < 0) return 0; if (n < r) return 0; std::uint64_t k = 1; for (std::uint64_t d = 1; d <= r; ++d) { k *= n--; k /= d; } return k; } bool isOK(i64 b, i64 n, i64 key) { i64 sum = 0; while (n > 0) { sum += n % b; n /= b; } if (sum == key) return true; } i64 binary_search(i64 n, i64 key) { i64 left = -1; i64 right = n + 1; while (right - left > 1) { i64 mid = left + (right - left) / 2; long double l = log(n) / log(mid); i64 num = floor(l) + 1; cout << mid << " " << num << endl; num *= (mid - 1); if (num >= key) right = mid; else left = mid; } return right; } signed main() { cin.tie(0); ios::sync_with_stdio(false); using P = pair; i64 N, D; cin >> N >> D; map left; for (i64 x = 1; x <= N; ++x) { for (i64 y = 1; y <= N; ++y) { left[x * x + y * y]++; } } i64 ans = 0; for (i64 z = 1; z <= N; ++z) { for (i64 w = 1; w <= N; ++w) { i64 n = z * z - w * w; if (left.count(D - n) == 0) continue; else ans += left[D - n]; } } cout << ans << endl; }