#include using namespace std; typedef long long ll; int main() { ll N, D; cin >> N >> D; int cnt = 0; for (int x = 1; x <= N; x++) { for (int y = x ; y <= N; y++) { for (int z = y; z <= N; z++) { int t = x * x + y * y + z * z - D; if (t > N * N) break; int k = sqrt(t); if (k * k == t) { if (x != y && y != z) cnt += 6; else if (x == y && y != z) cnt += 3; else if (x != y && y == z) cnt += 3; else cnt += 1; } } } } cout << cnt << "\n"; return 0; }