#include #include using namespace std; typedef long long ll; int main(void){ int n,d; ll ans = 0; cin >> n >> d; vector a(2*n*n+10),b(2*n*n+10); for(int x = 1;x <= n;x++){ for(int y = 1;y <= n;y++){ a[x*x+y*y]++; } } for(int w = 1;w <= n;w++){ for(int z = 1;z <= n;z++){ if(w*w-z*z+d < 0) continue; b[w*w-z*z+d]++; } } for(int i = 1;i <= 2*n*n;i++){ ans += (ll)a[i]*b[i]; } cout << ans << endl; }