#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using db = long double;
using ii = pair<int, int>;
const int N = 1e7 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ = 225;
const long double EPS = 1e-7;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  bitset<10000006> vis;
  for (ll i = 1; i <= n; i++) {
    ans += min(i * i, m) * 2;
    for (ll j = i - 1; j >= 0; --j) {
      if (i * i - j * j > m) break;
      if (!vis[i + j]) {
        vis[i + j] = true;
      } else
        ans--;
      if (!vis[i - j]) {
        vis[i - j] = true;
      } else
        ans--;
    }
  }
  cout << ans << '\n';
  return 0;
}
