#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000000 + 10;
pair<int, int> p[maxn];
int n, m, cnt;
long long res;
int main() {
  scanf("%d%d", &n, &m);
  int l = 0, r = m + 1;
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    if ((long long)mid * mid - m <= (long long)(mid - 1) * (mid - 1))
      l = mid;
    else
      r = mid;
  }
  int mm = l;
  if (n <= mm)
    for (int i = 1; i <= n; i++) res += min((long long)i * i, (long long)m);
  else {
    for (int i = 1; i <= mm; i++) res += min((long long)i * i, (long long)m);
    res += (long long)(n - mm) * m;
  }
  for (int i = 0, j = 0; i <= n; i++) {
    while (j + 1 <= n && (long long)(j + 1) * (j + 1) <= (long long)i * i + m)
      j++;
    if (j > i) {
      res -= j - i;
      p[cnt++] = make_pair(-j + i, -i - 1 + i);
      p[cnt++] = make_pair(-j - i, -i - 1 - i);
    }
  }
  res *= 2;
  sort(p, p + cnt);
  for (int i = 1; i < cnt; i++)
    if (p[i].first <= p[0].second)
      p[0].second = max(p[0].second, p[i].second);
    else {
      res += p[0].second - p[0].first + 1;
      p[0] = p[i];
    }
  if (cnt) res += p[0].second - p[0].first + 1;
  cout << res << endl;
}
