#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000000;
long long sq[MAXN + 10];
int getlow(long long val, int m) {
  int down = 0, up = m;
  while (down + 1 < up) {
    int mid = (down + up) >> 1;
    if (sq[mid] >= val) {
      up = mid;
    } else {
      down = mid;
    }
  }
  return up;
}
int main() {
  for (int i = 0; i <= MAXN; ++i) {
    sq[i] = (long long)i * i;
  }
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > yls;
  long long ret = 0;
  for (int b = 1; b <= n; ++b) {
    long long bb = (long long)b * b;
    int low, up;
    if (m >= bb) {
      low = 0;
    } else {
      low = getlow(bb - m, b);
    }
    up = b - 1;
    int tot = 0;
    if (m >= bb) {
      tot = (int)bb;
    } else {
      tot = m;
    }
    if (low <= up) {
      yls.push_back(make_pair(-b - up, -b - low));
      yls.push_back(make_pair(-b + low, -b + up));
      tot -= (up - low + 1);
    }
    ret += tot;
    ret += tot;
  }
  sort(yls.begin(), yls.end());
  if (!yls.empty()) {
    int lastend = yls[0].first - 2;
    int lastbegin = yls[0].first - 1;
    for (int i = 0; i < (int)yls.size(); ++i) {
      if (yls[i].first <= lastend + 1) {
        lastend = max(lastend, yls[i].second);
      } else {
        ret += (lastend - lastbegin + 1);
        lastbegin = yls[i].first;
        lastend = yls[i].second;
      }
    }
    ret += (lastend - lastbegin + 1);
  }
  cout << ret << endl;
  return 0;
}
