#include <bits/stdc++.h>
using namespace std;
const int DIM = 20000008;
const int POS = 10000004;
int arr[DIM];
int main(void) {
  int n, m;
  cin >> n >> m;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    long long l = max(0LL, 1LL * i * i - m), r = 1LL * i * i - 1;
    if (l == 0)
      ans += r - floor(sqrt(r));
    else
      ans += (r - l + 1) - (floor(sqrt(r)) - floor(sqrt(l - 1)));
    l = ceil(sqrt(l));
    r = floor(sqrt(r));
    ++arr[POS - i - r];
    --arr[POS - i - l + 1];
    ++arr[POS - i + l];
    --arr[POS - i + r + 1];
  }
  ans *= 2;
  for (int i = 1; i < DIM; ++i) {
    arr[i] += arr[i - 1];
    ans += (arr[i] > 0);
  }
  cout << ans << endl;
  return 0;
}
