#include using namespace std; int main(int argc, char *argv[]) { int N, D; cin >> N >> D; vector arr(N * N + N * N + D, 0); for (int x = 1; x <= N; x++) { for (int y = 1; y <= N; y++) { arr[x * x + y * y]++; } } int64_t ans = 0; for (int w = 1; w <= N; w++) { for (int z = 1; z <= N; z++) { int one = w * w - z * z + D; if (one >= 0) { ans += arr[one]; } } } cout << ans << endl; return 0; }