#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, d; cin >> n >> d; map mp; for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { mp[x * x + y * y]++; } } int ans = 0; for (int w = 1; w <= n; w++) { for (int z = 1; z <= n; z++) { int res = d + w * w - z * z; if (res < 2) continue; if (mp.count(res)) { ans += mp[res]; } } } cout << ans << endl; return 0; }