#include using namespace std; using ll = long long; const int MAXV = 5000000; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, d; cin >> n >> d; vector cnt1(MAXV + 1, 0); for (int x = 1; x <= n; x++) { for (int y = 1; y <= n; y++) { cnt1[x * x + y * y]++; } } vector cnt2(MAXV + 1, 0); for (int w = 1; w <= n; w++) { int lim = min(n * n, w * w + d); for (int z = 1; z * z <= lim; z++) { cnt2[d + w * w - z * z]++; } } ll ans = 0; for (int i = 0; i <= MAXV; i++) { ans += cnt1[i] * cnt2[i]; } cout << ans << endl; return 0; }