#include using namespace std; #define int long long signed main(){ cin.tie(0); ios::sync_with_stdio(false); int N,D; cin >> N >> D; vector xy,zw; for(int i = 1; i <= N; i++){ for(int j = 1; j <= N; j++){ xy.push_back(i*i + j*j); zw.push_back(i*i - j*j); } } sort(zw.begin(),zw.end()); int ans = 0; for(auto p : xy){ auto r = upper_bound(zw.begin(),zw.end(),D - p); auto l = lower_bound(zw.begin(),zw.end(),D - p); ans += r - l; } cout << ans << endl; return 0; }