#include <bits/stdc++.h>
using namespace std;
bool flag[100000005];
int main() {
  long long n, m, sum, b, t_sqrt, t, b_sq;
  while (cin >> n >> m) {
    sum = 0;
    memset(flag, 0, sizeof(flag));
    for (b = 1; b <= n; b++) {
      sum += min(m * 2, b * b * 2);
      b_sq = b * b;
      for (t_sqrt = b - 1; t_sqrt >= 0; t_sqrt--) {
        t = t_sqrt * t_sqrt;
        if (b_sq - t > m) break;
        if (flag[b - t_sqrt]) sum--;
        flag[b - t_sqrt] = true;
        if (flag[b + t_sqrt]) sum--;
        flag[b + t_sqrt] = true;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
