#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, k, ans = 0;
  cin >> n >> m;
  vector<pair<int, int> > v;
  for (long long b = 1; b <= n; b++) {
    ans += min(m, b * b) * 2;
    k = b * b > m ? b - sqrt(b * b - m) : b;
    if (k > 0) {
      ans -= k * 2;
      v.push_back(make_pair(1, k));
      v.push_back(make_pair((int)b * 2 - k, (int)b * 2 - 1));
    }
  }
  sort(v.begin(), v.end());
  int z = 0;
  for (int i = 0; i < (int)(v.size()); i++) {
    if (z > 0 && v[z - 1].second >= v[i].first)
      v[z - 1].second = v[i].second;
    else
      v[z++] = v[i];
  }
  for (int i = 0; i < (int)(z); i++) ans += (v[i].second - v[i].first + 1);
  cout << ans << endl;
  return 0;
}
