#include <bits/stdc++.h>
using namespace std;
int n, m;
bool g[10000005];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    long long ans = 0;
    memset(g, 0, sizeof(g));
    for (long long b = 1; b <= n; b++) {
      long long c = min(b * b, (long long)m);
      ans += 2 * c;
      long long a = 0, o;
      if (b * b > m) {
        o = sqrt(b * b - m);
        if (o * o + m == b * b)
          a = o;
        else
          a = o + 1;
      }
      long long u = sqrt(b * b - 1);
      for (; a <= u; a++) {
        long long x1 = -b + a, x2 = -b - a;
        if (!g[-x1])
          g[-x1] = 1;
        else
          ans--;
        if (!g[-x2])
          g[-x2] = 1;
        else
          ans--;
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
