#include "bits/stdc++.h" using namespace std; void solve() { int N, D, ans = 0; cin >> N >> D; vector mp(N*N*2+1); for (int y = 1; y <= N; y++) { for (int z = 1; z <= N; z++) { int s = y*y+z*z; if (s<=N*N*2) mp[s]++; } } for (int x = 1; x <= N; x++) { for (int w = 1; w <= N; w++) { int p = D + w * w - x * x; if (p > N*N*2 || p < 0) continue; ans += mp[p]; } } cout << ans << endl; } int main(void) { solve(); //cout << "yui(*-v・)yui" << endl; return 0; }