#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long minds = 0, maxds = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long up = i * i - 1, down = i * i - m;
    down = max(0ll, down);
    while (up >= maxds * maxds) maxds++;
    while (down > minds * minds) minds++;
    ans += max(0ll, up - down + 1ll - (maxds - minds));
  }
  ans *= 2ll;
  for (int i = 1; i <= 11000000; i++)
    if (i % 2 == 1 && (i + 1) / 2ll <= n && i <= m)
      ans++;
    else if ((i + 2) / 2 <= n && i * 2ll <= m)
      ans++;
  cout << ans;
  return 0;
}
