#include <bits/stdc++.h>
using namespace std;
int const SP = 15000000;
char nnew[SP + 100];
long long ans;
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int b = 1; b <= n; b++) {
    int j = b - 1;
    long long b2 = b * (b + 0LL);
    long long cnt = min(m + 0LL, b2);
    while (1) {
      long long p = j * (j + 0LL);
      if (j < 0) break;
      if (p < b2 - m) break;
      nnew[-b + j + SP] = 1;
      nnew[-b - j + SP] = 1;
      cnt--;
      j--;
    }
    ans += cnt * 2;
  }
  for (int i = -2 * n; i <= 0; i++) ans += nnew[i + SP];
  cout << ans;
  return 0;
}
