#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for (int i = 0; i < (int)(n); ++i) //#define cerr if(false) cerr #define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__); using namespace std; using ll = long long; using pii = pair; template ostream &operator<<(ostream &os, pair a){ os << '(' << a.first << ',' << a.second << ')'; return os; } template ostream &operator<<(ostream &os, vector v){ for(auto x:v)os << x << ' '; return os; } void debug(){cerr << '\n';} template void debug(H a, T... b){ cerr << a; if(sizeof...(b))cerr << ", "; debug(b...); } int main(){ ll n,d; cin >> n >> d; mapmp; for(ll i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ mp[i*i-j*j]++; } } ll ans = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ ans += mp[i*i+j*j-d]; } } cout << ans << endl; }