#include <bits/stdc++.h>
using namespace std;
int N, M;
inline long long sqr(long long x) { return x * x; }
inline long long nonSquareLE(long long x) {
  x = max(x, (long long)0);
  long long lo = 0, hi = (1LL << 25);
  while (lo < hi) {
    long long mid = (lo + hi + 1) >> 1;
    if (sqr(mid) <= x) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  return x - hi;
}
inline long long calc() {
  long long ret = 0;
  int maxval = 2 * N;
  for (long long x = 1; x <= maxval; x++) {
    long long b = (x + 2) / 2;
    if (b >= 1 && b <= N) {
      long long c = (2 * b - x) * x;
      if (c >= 1 && c <= M) {
        ret++;
      }
    }
  }
  return ret;
}
int main() {
  cin >> N >> M;
  long long ans = calc();
  for (int i = 1; i <= N; i++) {
    ans += ((nonSquareLE(sqr(i) - 1) - nonSquareLE(sqr(i) - M - 1)) << 1);
  }
  cout << ans << endl;
  return 0;
}
