#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  while (scanf("%I64d%I64d", &n, &m) != EOF) {
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      if (m > i * i) ans += (i * i - 1) * 2 + 1;
      if (m < i * i) ans += 2 * m;
      if (m == i * i) ans += 2 * (m - 1) + 1;
      if (i > 1) {
        long long mm = m;
        if (i <= 2) {
          if (mm >= 3) ans--;
        } else {
          if (mm >= i * i)
            ans -= (2 * i - 3);
          else if (mm >= (i * i - (i - 2) * (i - 2))) {
            ans -= 2;
            double ii = (double)i, kk = (double)mm;
            double p = sqrt(ii * ii - kk);
            long long pp = (long long)p;
            if (p - pp > 0) pp++;
            pp = i - pp;
            ans -= 2 * (pp - 2);
          } else {
            if (mm >= (i * i - (i - 1) * (i - 1))) ans--;
          }
        }
      }
    }
    printf("%I64d\n", ans);
  }
}
