#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int x;
  scanf("%d", &x);
  return x;
}
string nextString() {
  char s[20];
  scanf("%s", &s);
  return s;
}
long long numbersCount(long long a, long long b) {
  if (a > b) {
    return 0;
  }
  return b - a + 1;
}
long long squaresCount(long long a) {
  if (a < 0) {
    return 0;
  }
  if (a == 0) {
    return 1;
  }
  return sqrt((double)a) + 1e-9 + 1;
}
long long squaresCount(long long a, long long b) {
  if (a > b) {
    return 0;
  }
  return squaresCount(b) - squaresCount(a - 1);
}
long long sqr(long long a) { return a * a; }
long long solve(long long n, long long m) {
  long long minInt = INT_MAX;
  long long maxInt = -INT_MAX;
  long long irrCount = 0;
  vector<pair<int, int> > v;
  for (long long b = 1; b <= n; ++b) {
    if (sqr(b - 1) >= sqr(b) - m) {
      {
        long long from = -b - (b - 1);
        long long to =
            m >= b * b ? -b : -b - ceil(sqrt((double)b * b - m) - 1e-9);
        if (from <= to) v.push_back(make_pair(from, to));
      }
      {
        long long from =
            m >= b * b ? -b : -b + floor(sqrt((double)b * b - m) + 1e-9);
        long long to = -b + (b - 1);
        if (from <= to) v.push_back(make_pair(from, to));
      }
    }
    long long from = max(0LL, b * b - m);
    long long to = b * b - 1;
    long long A = numbersCount(from, to);
    long long B = squaresCount(from, to);
    irrCount += 2 * (A - B);
  }
  long long res = irrCount;
  sort(v.begin(), v.end());
  int hi = INT_MIN;
  int lo = INT_MIN + 1;
  for (int i = 0; i < v.size(); ++i) {
    if (v[i].first > hi) {
      res += hi - lo + 1;
      lo = v[i].first;
    }
    hi = max(hi, v[i].second);
  }
  res += hi - lo + 1;
  return res;
}
int cmp(double x) {
  double eps = 1e-9;
  return x < -eps ? -1 : x > eps ? 1 : 0;
}
bool solve2(double a, double b, double c, double &x1, double &x2) {
  if (cmp(a) == 0) {
    if (cmp(b) == 0) {
      if (cmp(c) == 0) {
        x1 = x2 = 0;
        return true;
      } else {
        return false;
      }
    } else {
      x1 = x2 = -c / b;
      return true;
    }
  } else {
    double d = b * b - 4 * a * c;
    if (cmp(d) < 0) {
      return false;
    }
    d = cmp(d) == 0 ? 0 : sqrt(d);
    x1 = (-b + d) / (2 * a);
    x2 = (-b - d) / (2 * a);
    return true;
  }
}
int brute(int n, int m, vector<double> &roots) {
  roots.clear();
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      double x1, x2;
      if (solve2(1, 2 * i, j, x1, x2)) {
        roots.push_back(x1);
        roots.push_back(x2);
      }
    }
  }
  sort(roots.begin(), roots.end());
  int res = 1;
  for (int i = 1; i < roots.size(); ++i) {
    if (roots[i] - roots[i - 1] > 1e-9) {
      ++res;
    }
  }
  return res;
}
int main() {
  long long n = nextInt();
  long long m = nextInt();
  long long res = solve(n, m);
  cout << res << endl;
  return 0;
}
