#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){ for (int y = 1; y <= N; ++y){ ++freq[x*x + y*y]; } } long long ans = 0; for (int z = 1; z <= N; ++z){ for (int w = 1; w <= N; ++w){ int tmp = w * w + D - z * z; if (tmp > 0) ans += freq[tmp]; } } cout << ans << endl; return 0; }