#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template string to_string(pair p); template string to_string(tuple p); template string to_string(tuple p); string to_string(const string& s) { return '"' + s + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(bool b) { return (b ? "true" : "false"); } string to_string(vector v) { bool first = true; string res = "{"; for (int i = 0; i < static_cast(v.size()); i++) { if (!first) { res += ", "; } first = false; res += to_string(v[i]); } res += "}"; return res; } template string to_string(bitset v) { string res = ""; for (size_t i = 0; i < N; i++) { res += static_cast('0' + v[i]); } return res; } template string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } template string to_string(pair p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template string to_string(tuple p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")"; } template string to_string(tuple p) { return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")"; } void debug_out() { cerr << endl; } template void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif using Int = unsigned int; using llong = long long; using Llong = unsigned long long; using ldouble = long double; using intV = vector; using llongV = vector; using llongVV = vector>; template using asc_pque = priority_queue, greater>; template using desc_pque = priority_queue, less>; const llong MOD = 1000000007; const int IINF = 1000000000; const llong LINF = 100000000000000000LL; #define FOR(i, n) for (llong i = 0LL; i < llong(n); i++) #define FORS(i, a, b) for (llong i = llong(a); i < llong(b); i++) #define sup(vec, a) upper_bound(vec.begin(), vec.end(), a) - vec.begin() #define inf(vec, a) lower_bound(vec.begin(), vec.end(), a) - vec.begin() #define GET(i, T) get(T) int main(void) { cin.tie(0); ios::sync_with_stdio(false); llong N, D; cin >> N >> D; map V; FORS(y, 1, N + 1) { FORS(z, 1, N + 1) { V[y * y + z * z] += 1; } } llong ans = 0; FORS(w, 1, N + 1) { FORS(x, 1, N + 1) { llong E = D + w * w - x * x; if(E < 0) break; ans += V[E]; } } cout << ans << endl; return 0; }