#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, D; cin >> N >> D; map mp; for (int x = 1; x < N + 1; x++) { for (int y = 1; y < N + 1; y++) { mp[x * x + y * y]++; } } int res = 0; for (int z = 1; z < N + 1; z++) { for (int w = 1; w < N + 1; w++) { res += mp[D + w * w - z * z]; } } cout << res << '\n'; return 0; }