#include #include #include using namespace std; using ll = long long; void ins() {} templatevoid ins(T& v,Rest&... rest){cin>>v;ins(rest...);} #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) int main() { int N, D; ins(N, D); map m, m2; rep(i, N) rep(j, N) { ++m[(i+1)*(i+1)+(j+1)*(j+1)]; ++m2[(i+1)*(i+1)-(j+1)*(j+1)]; } ll ans = 0; for (const auto& [wz, count]:m2) { ans += m[wz+D] * count; } cout << ans << endl; return 0; }