#include using namespace std; using i64 = long long; #define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++) #define all(x) x.begin(),x.end() i64 mp[2000 * 2000 * 2 + 10]; int main() { i64 N,D; cin >> N >> D; rep(i,1,N) rep(j,1,N) { mp[j * j - i * i + 2000 * 2000]++; } i64 ans = 0; rep(i,1,N) rep(j,1,N) { i64 XX = i * i + j * j - D + 2000 * 2000; if(XX < 0 || XX >= 2000 * 2000 * 2 + 10) continue; ans += mp[XX]; } cout << ans << endl; }