#include #include #include using namespace std; using ll = long long; void ins() {} templatevoid ins(T& v,Rest&... rest){cin>>v;ins(rest...);} #define _overload3(_1,_2,_3,name,...) name #define _rep2(i,n) for(int i=0,_i=(n);i<_i;++i) #define _rep3(i,a,b) for(int i=(a),_i=(b),_ii=(b)>(a)?1:-1;abs(_i-i)>0;i+=_ii) #define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__) constexpr int MAX_N = 3000; int m[MAX_N*MAX_N+1], m2[MAX_N*MAX_N+1]; int main() { int N, D; ins(N, D); rep(i, MAX_N*MAX_N+1) m[i] = m2[i] = 0; m2[0] += N; rep(i, N) { ++m[2*(i+1)*(i+1)]; rep(j, i+1, N) { m[(i+1)*(i+1)+(j+1)*(j+1)] += 2; ++m2[(j+1)*(j+1)-(i+1)*(i+1)]; } } ll ans = 0; rep(i, MAX_N*MAX_N+1) { ans += m2[abs(i-D)] * m[i]; } cout << ans << endl; return 0; }