#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
const int ADD = 2 * 10000000 + 10;
char u[ADD * 2];
long long n, m;
long long S;
struct qu {
  static const int N = ADD / 4;
  int ar[N];
  int s, f, size;
  qu() {
    s = f = size = 0;
    memset(ar, 0, sizeof(ar));
    ;
  }
  void push(int x) {
    ar[f] = x;
    f = (f + 1) % N;
    size++;
  }
  void pop() {
    s = (s + 1) % N;
    size--;
  }
};
qu q;
void relax(long long root) {
  if (u[ADD + root]) return;
  u[ADD + root] = 1;
  S++;
}
int main() {
  cin >> n >> m;
  long long c = 0;
  for (long long b = 1; b <= n; b++) {
    while (c * c < b * b) q.push(c++);
    while (q.s != q.f && ((long long)q.ar[q.s] * q.ar[q.s]) < b * b - m)
      q.pop();
    for (int i = q.s; i != q.f; i = (i + 1) % q.N) {
      relax(-2 * b - 2 * q.ar[i]);
      relax(-2 * b + 2 * q.ar[i]);
    }
    S += (((long long)b * b - 1) - max((b * b - m), 0ll) + 1 - q.size) * 2;
  }
  cout << S << endl;
  return 0;
}
