#include <bits/stdc++.h>
using namespace std;
long long sqr(long long x) { return (long long)(x * x); }
long long my_abs(long long x) {
  if (x < 0) return -x;
  return x;
}
const int MN = 1000 * 1000 * 10;
int main() {
  long long ans = 0;
  long long n, m;
  cin >> n >> m;
  for (long long b = 1; b <= n; b++) {
    long long mx_c = min(b * b, m);
    long long tmp_ans = 2ll * (long long)(mx_c);
    long long up = (long long)sqrt(sqr(b) - 1.0);
    long long down = (long long)ceil(sqrt((double)(sqr(b) - (long long)mx_c)));
    if (down > up) {
      ans += tmp_ans;
      continue;
    }
    tmp_ans -= 2ll * (up - down + 1ll);
    ans += tmp_ans;
  }
  for (int x = -MN; x <= -1; x++) {
    int tmp1, tmp2;
    if (abs(x) % 2 == 0) {
      tmp1 = abs(x - 2) / 2;
      tmp2 = abs(x * 2);
    } else {
      tmp1 = abs(x - 1) / 2;
      tmp2 = abs(x);
    }
    if (tmp1 <= n && tmp2 <= m) ans++;
  }
  cout << ans;
  return 0;
}
