#include using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, d; cin >> n >> d; map m; for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { int val = x * x + y * y; m[val]++; } } ll ans = 0; for (int z = 1; z <= n; z++) { for (int w = 1; w <= n; w++) { int val = d + w * w - z * z; if (m.find(val) == m.end()) continue; ans += m[val]; } } cout << ans << endl; return 0; }