#include <bits/stdc++.h>
using namespace std;
const int MAX_N = (int)1e7 + 10;
int n, m;
long long answer;
int oldCnt[MAX_N], *cnt = oldCnt + MAX_N - 2;
void addInterval(int l, int r) {
  cnt[l]++;
  cnt[r + 1]--;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int t = 0;; ++t) {
    int l = ceil(sqrt(1LL * t * t + 1.0));
    int r = floor(sqrt(1LL * t * t + m + 0.0));
    r = min(r, n);
    if (l > r) {
      break;
    }
    addInterval(-r + t, -l + t);
    addInterval(-r - t, -l - t);
  }
  for (int i = 0, sum = 0; i < MAX_N; ++i) {
    sum += oldCnt[i];
    if (sum > 0) {
      answer -= sum - 1;
    }
  }
  for (int c = 1; c <= m; ++c) {
    int l = ceil(sqrt(c));
    if (l > n) {
      break;
    }
    answer += (n - l + 1) << 1;
  }
  cout << answer << endl;
}
