#include using namespace std; int main() { int n, d; cin >> n >> d; int O = 8'000'010; vector V(O*2+1, 0); vector W(O*2+1, 0); for(int x = 1; x <= n; x++) { for(int y = 1; y <= n; y++) { V[x * x + y * y + O]++; } } for(int z = 1; z <= n; z++) { for(int w = 1; w <= n; w++) { W[w * w - z * z + d + O]++; } } int ans = 0; for(int i = -O; i <= O; i++) { ans += V[i+O] * W[i+O]; } cout << ans << endl; return 0; }