#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define int long long int #define rep(i, n) for(int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) using namespace std; typedef pair P; const int INF = 1e15; const int MOD = 1e9+7; template using vector2 = vector>; template vector2 initVec2(size_t n0, size_t n1, T e = T()){ return vector2(n0, vector(n1, e)); } template using vector3 = vector>>; template vector3 initVec3(size_t n0, size_t n1, size_t n2, T e = T()){ return vector3(n0, vector2(n1, vector(n2, e))); } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n, d; cin >> n >> d; vector a(2 * n * n + 1); for(int x = 1; x <= n; x++){ for(int y = 1; y <= n; y++){ a[x*x+y*y]++; } } int ans = 0; for(int x = 1; x <= n; x++){ for(int y = 1; y <= n; y++){ int tmp = x * x + d - y * y; if(tmp < 0){ continue; } ans += a[tmp]; } } cout << ans << endl; return 0; }