#include using namespace std; int main() { int N, D; cin >> N >> D; vector V(N * N * 2 + D + 1); for (int x = 1; x <= N; x++) { for (int y = 1; y <= N; y++) V.at(x * x + y * y)++; } int ans = 0; for (int w = 1; w <= N; w++) { for (int z = 1; z <= N; z++) { int tmp = w * w - z * z + D; if (0 <= tmp && tmp < (int) V.size()) ans += V.at(tmp); } } cout << ans << "\n"; }