#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { int64_t n, d; cin >> n >> d; int64_t ans = 0; for (int64_t x = 1; x <= n; x++) { for (int64_t y = 1; y <= n; y++) { for (int64_t z = 1; z <= n; z++) { if (x * x + y * y + z * z - d <= 0) { continue; } int64_t w = round(sqrt(x * x + y * y + z * z - d)); if (n < w) { break; } if (x * x + y * y + z * z == w * w + d) { ans++; } } } } cout << ans << endl; return 0; }