#include <bits/stdc++.h>
using namespace std;
const int mxn = 5000000;
int op[4 * mxn];
int cl[4 * mxn];
inline void addRange(int lo, int hi) {
  op[(lo + 2 * mxn)]++;
  cl[(hi + 2 * mxn)]++;
}
int main() {
  int n, m;
  cin >> n >> m;
  long long ans = 0;
  for (int b = 1; b <= n; b++) {
    long long b2 = b * (long long)b;
    long long hi = b2 - 1;
    long long lo = max(0LL, b2 - m);
    long long lq = sqrt(lo);
    long long hq = sqrt(hi);
    long long roots = hq - lq + (lq * lq == lo);
    if (roots >= 1) {
      while (lq * lq < lo) lq++;
      addRange(-b - hq, -b - lq);
      addRange(-b + lq, -b + hq);
    }
    ans += 2 * ((hi - lo + 1) - roots);
  }
  int in = 0;
  for (int i = 0; i < 4 * mxn; i++) {
    in += op[i];
    if (in > 0) {
      ans++;
    }
    in -= cl[i];
  }
  cout << ans << endl;
  return 0;
}
