#include <bits/stdc++.h>
using namespace std;
int f[10000001];
int main() {
  int n, m, l, r;
  scanf("%d%d", &n, &m);
  long long ans = 0;
  int Max0 = max(n * 2, m);
  for (long long b = 1; b <= n; ++b) {
    ans += 2 * min(b * b, (long long)m);
    l = max(0, int(ceil(sqrt(b * b - m))));
    r = int(floor(sqrt(b * b - 1)));
    ++f[-b - r + Max0], --f[-b - l + 1 + Max0], ++f[-b + l + Max0],
        --f[-b + r + 1 + Max0];
  }
  int s = 0;
  for (int i = 0; i < Max0; ++i) {
    s += f[i];
    if (s > 1) ans -= s - 1;
  }
  printf("%I64d\n", ans);
  return 0;
}
