#include using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, D; cin >> N >> D; vector freq(2 * N * N + 1 + D, 0); for (int x = 1; x <= N; ++x){ ++freq[x*x*2]; for (int y = x + 1; y <= N; ++y){ freq[x*x + y*y] += 2; } } long long ans = 0; for (int w = 1; w <= N; ++w){ int wd = w * w + D; for (int z = 1; z <= N; ++z){ int tmp = wd - z * z; if (tmp < 0) break; ans += freq[tmp]; } } cout << ans << endl; return 0; }