#include <bits/stdc++.h>
using namespace std;
long long n, m, answer;
long long countPS(long long a) {
  if (a <= 0) return 0;
  long long aq = (long long)sqrt((double)a + 0.01);
  return aq;
}
int main() {
  scanf("%lld %lld", &n, &m);
  answer = 0;
  for (long long b = 1; b <= n; b++) {
    long long cmax = b * b - 1;
    if (cmax > m) cmax = m;
    if (cmax == 0) continue;
    answer += 2 * (cmax - countPS(b * b - 1) + countPS(b * b - cmax - 1));
  }
  for (int r = 1; r <= m + 1; r++) {
    int bval, cval;
    if (!(r & 1)) {
      bval = (r + 2) / 2;
      cval = r * 2;
    } else {
      bval = (r + 1) / 2;
      cval = r;
    }
    if (bval <= n && cval <= m) {
      answer++;
    }
  }
  printf("%lld\n", answer);
}
