#include <bits/stdc++.h>
using namespace std;
long long int sum, s, n, m;
bool bo[100000000] = {};
int main() {
  cin >> n >> m;
  s = 0;
  for (long long int i = 1; i <= n; ++i) {
    long long int c = min(i * i, m);
    for (long long int x = (long long int)sqrt(max(i * i - m, 0LL));
         (i * i - x * x) >= 1; ++x) {
      if ((i * i - x * x) > m) continue;
      c--;
      if (!bo[x - i + 10000000]) {
        bo[x - i + 10000000] = 1;
        s++;
      }
      if (!bo[-x - i + 10000000]) {
        bo[-x - i + 10000000] = 1;
        s++;
      }
    }
    sum += c * 2;
  }
  cout << sum + s << endl;
  return 0;
}
