#include using namespace std; #define REP(i,n) for (int i=0;i<(n);i++) #define REP2(i,m,n) for (int i=m;i<(n);i++) typedef long long ll; ll N, D; void solve() { cin >> N >> D; unordered_map cnt; REP2 (z, 1, N+1) REP2 (w, 1, N+1) cnt[z*z-w*w] += 1; ll ans = 0; REP2 (x, 1, N+1) { REP2 (y, 1, N+1) { if (cnt.find(D-x*x-y*y) != cnt.end()) { ans += cnt[D-x*x-y*y]; } } } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }