#include using namespace std; using llong = long long; using ldbl = long double; using P = pair; #define BE(x) x.begin(), x.end() const llong inf = llong(1e18)+7; const llong mod = 1e9+7; int main(){ int N, D; cin >> N >> D; int ans = 0; vector> ok(N*N*2+1); for(int i = 1; i <= N; i++) for(int j = i; j <= N; j++) ok[i*i+j*j].push_back(P(i,j)); for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++){ int check = D - (j*j - i*i); if(check < 0) break; if(check > N*N*2) continue; for(auto &x : ok[check]){ if(x.first == x.second) ans++; else ans += 2; } } cout << ans << endl; return 0; }