#include <bits/stdc++.h>
using namespace std;
char tree[33554432];
const int BASE = 16777216;
int st, ed;
void cover(int now, int s, int e) {
  if (st <= s && e <= ed) {
    tree[now] = 1;
  } else {
    int m = (s + e) / 2;
    if (st <= m) cover(now * 2, s, m);
    if (m + 1 <= ed) cover(now * 2 + 1, m + 1, e);
  }
}
int get(int now, int s, int e) {
  if (tree[now]) {
    return e - s + 1;
  }
  if (now >= BASE) return 0;
  int m = (s + e) / 2;
  return get(now * 2, s, m) + get(now * 2 + 1, m + 1, e);
}
int main() {
  memset(tree, 0, sizeof(tree));
  int _n, _m;
  long long n, m;
  scanf("%d%d", &_n, &_m);
  n = _n, m = _m;
  long long isol = 0;
  long long dsol = 0;
  for (long long i = 1; i <= _n; ++i) {
    if (i * i > m) {
      double s1 = sqrt(i * i - 1);
      double s2 = sqrt(i * i - m);
      int cnt = (int)((double)i - s2 + 1e-9);
      if (cnt > 0) {
        st = 2 * i - cnt;
        ed = 2 * i - 1;
        cover(1, 0, BASE - 1);
        st = 1;
        ed = cnt;
        cover(1, 0, BASE - 1);
      }
      dsol += 2 * m - 2 * cnt;
    } else {
      st = 1, ed = 2 * i - 1;
      cover(1, 0, BASE - 1);
      dsol += 2 * i * i - 2 * i;
    }
  }
  isol = get(1, 0, BASE - 1);
  cout << dsol + isol << endl;
}
