#include using namespace std; typedef long long ll; int main() { int N, D; cin >> N >> D; int n = 2 * N * N + 1; int d[n]{}; for (int x = 1; x <= N; x++) { for (int y = 1; y <= N; y++) { d[x * x + y * y]++; } } int cnt = 0; for (int z = 1; z <= N; z++) { for (int w = 1; w <= N; w++) { int t = w * w - z * z + D; if (t >= 0 && t <= n - 1) { cnt += d[t]; } } } cout << cnt << "\n"; return 0; }