#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T x, T y) {
  while (T t = x % y) x = y, y = t;
  return y;
}
const double eps = 1e-10;
const double PI = acos(-1.);
const int INF = 1000000000;
const int MOD = 1000000007;
const double E = 2.7182818284590452353602874713527;
bool isdig(char x) { return x >= '0' && x <= '9'; }
bool isup(char x) { return x >= 'A' && x <= 'Z'; }
bool islow(char x) { return x >= 'a' && x <= 'z'; }
bool islet(char x) { return isup(x) || islow(x); }
int N, M;
void get_data() { cin >> N >> M; }
long long cal(long long e, long long s) {
  s = max(1LL, s);
  long long a, b;
  a = sqrt(s);
  b = sqrt(e);
  while (a * a > s) a--;
  while (a * a < s) a++;
  while (b * b < e) b++;
  while (b * b > e) b--;
  return max(0LL, b - a + 1);
}
void run() {
  long long r = 0;
  for (int i = 1; i <= N; i++) {
    long long t = i;
    r -= cal(t * t - 1, t * t - M) * 2;
    r += min(t * t - 1, (long long)M) * 2;
  }
  for (int i = 1; i <= N * 2; i++) {
    if (i % 2 == 0) {
      if (i * 2 <= M && i + 2 <= N * 2) r++;
    } else {
      if (i <= M && i + 1 <= N * 2) r++;
    }
  }
  cout << r << endl;
}
int main(int argc, char *argv[]) {
  {
    get_data();
    run();
  }
  return EXIT_SUCCESS;
}
