#include "bits/stdc++.h" #define in std::cin #define out std::cout #define rep(i,N) for(LL i=0;i> N >> D; std::vectorcnt1(8123456), cnt2(8123456); for (LL x = 1; x <= N; ++x) for (LL y = 1; y <= N; ++y) ++cnt1[x*x + y * y]; for (LL w = 1; w <= N; ++w) for (LL z = 1; z <= N; ++z) ++cnt2[w*w - z * z + D]; LL ans = 0; for (LL i = 1; i <= 2 * N * N; ++i) ans += cnt1[i] * cnt2[i]; out << ans << std::endl; }