#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int64_t n, m;
  std::cin >> n >> m;
  std::unordered_set<int64_t> integers;
  int64_t irrationals = 0;
  for (int64_t b = 1; b <= n; ++b) {
    irrationals += std::min(b * b, m) * 2;
    int64_t local = 0;
    for (int64_t next = b - 1; next >= 0; --next) {
      if (b * b - next * next <= m) {
        local += 1;
        integers.insert(-b + next);
        integers.insert(-b - next);
        irrationals -= 2;
      } else {
        break;
      }
    }
  }
  std::cout << integers.size() + irrationals << '\n';
}
