#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  vector<long long> vp(5000000);
  for (int i = 0; i < 5000000; i++) {
    vp[i] = (long long)i * i;
  }
  static bool mem[20000001];
  while (cin >> n >> m) {
    memset(mem, false, sizeof(mem));
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += 2 * min(m, (long long)i * i);
      int s =
          lower_bound(vp.begin(), vp.end(), (long long)i * i - m) - vp.begin();
      int e =
          upper_bound(vp.begin(), vp.end(), (long long)i * i - 1) - vp.begin();
      if (s != e) {
        for (int j = s; j < e; j++) {
          ans -= 2;
          if (!mem[-i + j + 10000000]) {
            mem[-i + j + 10000000] = true;
            ans++;
          }
          if (!mem[-i - j + 10000000]) {
            mem[-i - j + 10000000] = true;
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
