#include using namespace std; using ll = long long; ll xy[2001*4001]; int main(){ ll n,d; cin >> n >> d; for(ll x=1;x <= n;x++){ for(ll y=1;y <= n;y++){ xy[x*x + y*y]++; } } ll ans = 0; for(ll w=1;w <= n;w++){ for(ll z=1;z <= n;z++){ ll X = w*w - z*z + d; if(X >= 0) ans += xy[X]; } } cout << ans << endl; return 0; }