#include <bits/stdc++.h>
using namespace std;
bool is_square(long long x) {
  long long y = sqrt(x);
  return (y * y == x);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  map<long long, int> mp;
  long long sol = 0;
  int n, m;
  cin >> n >> m;
  for (int b = 1; b <= n; b++) {
    int lim = min((long long)b * b, (long long)m);
    long long l = (long long)b * b - lim, r = (long long)b * b - 1;
    r = sqrt(r);
    if (is_square(l)) {
      l = sqrt(l);
    } else {
      l = sqrt(l) + 1;
    }
    if (l <= r) {
      mp[-b + l]++;
      mp[-b + r + 1]--;
      mp[-b - r]++;
      mp[-b - l + 1]--;
    }
    sol += 2LL * (lim - (r - l + 1));
  }
  long long cur = 0, ant;
  for (auto &it : mp) {
    if (cur) {
      sol += it.first - ant;
    }
    ant = it.first;
    cur += it.second;
  }
  cout << sol << "\n";
  return 0;
}
