#include <bits/stdc++.h>
int main() {
  long long n, m;
  long long i, j, k;
  long long resu = 0;
  scanf("%I64d%I64d", &n, &m);
  for (i = 1; i <= n; i++) {
    k = i * i;
    if (k > m)
      resu += 2 * m;
    else
      resu += 2 * k;
  }
  long long a, b, c, d, e, f, g, h, delta;
  for (a = -1; a >= -m; a--) {
    c = -(m / (-a));
    d = -1;
    e = -2 * n - a;
    f = -1 - a;
    if (d < e) continue;
    h = d;
    if (c < e)
      g = e;
    else
      g = c;
    if (h >= g) {
      delta = (h - g + 1) / 2 + (((-a) & 1) && ((h - g + 1) & 1));
      if (delta > 0) {
        resu -= delta - 1;
        if (a * a >= 1 && a * a <= m && (-a - a) >= 1 && (-a - a) <= 2 * n)
          resu -= 1;
      }
    }
  }
  printf("%I64d\n", resu);
  return 0;
}
