#include #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = std::int64_t; using P = std::tuple; int N, D; std::vector v, w; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N >> D; for(int i=1;i<=N;++i){ for(int j=1;j<=N;++j){ v.emplace_back(i * i + j * j); w.emplace_back(- i * i + j * j + D); } } std::sort(v.begin(), v.end()); std::sort(w.begin(), w.end()); ll cnt = 0; int i = 0, j = 0; for(int s : v){ while(i < w.size() && w[i] < s){ i += 1; } j = i; while(j < w.size() && w[j] <= s){ j += 1; } if(i < w.size() && w[i] == s){ cnt += j - i; } } std::cout << cnt << std::endl; }