#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; //#define int long long #define rep(i, n) for (int i=0;i<(int)(n);++i) #define rep1(i, n) for (int i=1;i<=(int)(n);++i) #define range(i, l, r) for (int i=l;i<(int)(r);++i) #define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i) #define unless(a) if(!(a)) #define all(a) begin(a),end(a) #define fst first #define scd second #define PB emplace_back #define PPB pop_back using vi=vector; using pii=pair; using ll=long long; bool chmin(int&a,int b){return a>b?(a=b,true):false;} bool chmax(int&a,int b){return a zw; signed main() { cin >> N >> D; range(z, 1, N + 1) { range(w, 1, N + 1) { zw[z * z - w * w]++; } } ll ans = 0; range(x, 1, N + 1) { range(y, 1, N + 1) { if (zw.count(D - (x * x + y * y))) ans += zw[D - (x * x + y * y)]; } } printf("%lld\n", ans); }