#include <bits/stdc++.h>
using namespace std;
long long n, m, ans;
bool X[15500000];
const int SHIFT = 10000000;
int main() {
  cin >> n >> m;
  ans = n * m * 2;
  memset(X, 0, sizeof(X));
  for (long long b = 1; b <= n; b++) {
    long long tmp = b;
    if (b * b < m) ans -= 2 * (m - b * b);
    while (1) {
      --tmp;
      long long delta = b * b - tmp * tmp;
      if (delta > m || tmp < 0) break;
      if (X[-b + tmp + SHIFT] == 0) {
        X[-b + tmp + SHIFT] = 1;
      } else
        ans--;
      if (X[-b - tmp + SHIFT] == 0) {
        X[-b - tmp + SHIFT] = 1;
      } else
        ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
