#include <bits/stdc++.h>
using namespace std;
struct S {
  int ind;
  bool st;
  S(int ind, bool st) : ind(ind), st(st) {}
};
int n, m;
long long ans = 0;
vector<S> s;
inline bool cmp(const S &lhs, const S &rhs) { return lhs.ind < rhs.ind; }
int main() {
  cin >> n >> m;
  for (int b = 1; b <= n; ++b) {
    int lo = 0, hi = b, mid;
    long long b2 = (long long)b * b;
    while (lo < hi) {
      mid = (lo + hi) >> 1;
      if (b2 - (long long)mid * mid > m)
        lo = mid + 1;
      else
        hi = mid;
    }
    ans += 2 * min(b2, (long long)m) - (m >= b2) - 2 * (b - lo) + (lo == 0);
    if (lo < b) {
      int from = lo;
      int to = b - 1;
      s.push_back(S(-b - to, true));
      s.push_back(S(-b - from + 1, false));
      s.push_back(S(-b + from, true));
      s.push_back(S(-b + to + 1, false));
    }
  }
  s.push_back(S((int)1e9, true));
  sort(s.begin(), s.end(), cmp);
  int pre = -1e9;
  int bal = 0;
  for (S x : s) {
    if (bal > 0) {
      ans += x.ind - pre;
    }
    if (x.st)
      ++bal;
    else
      --bal;
    pre = x.ind;
  }
  cout << ans << endl;
  return 0;
}
