#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } char ToUpper(char cX) { return toupper(cX); } char Tolower(char cX) { return tolower(cX); } const long long INF = 1LL << 60; const long long MOD = 1000000007LL; const long long MAX = 500000LL; using namespace std; typedef unsigned long long ull; typedef long long ll; using T = tuple; int main() { ll N, D; cin >> N >> D; vector sum1; for (ll x = 1; x <= N; x++) { for (ll y = 1; y <= N; y++) { sum1.push_back(x * x + y * y); } } sort(sum1.begin(), sum1.end()); ll res = 0; for (ll z = 1; z <= N; z++) { for (ll w = 1; w <= N; w++) { ll temp = w * w + D - z * z; res += upper_bound(sum1.begin(), sum1.end(), temp) - lower_bound(sum1.begin(), sum1.end(), temp); } } cout << res << endl; return 0; }