#include <bits/stdc++.h>
using namespace std;
const double pi = 3.1415926535;
const double eps = 1e-6;
long long ans = 0;
int del = 10000010;
int la[20000100], n, m;
void ins(int a, int b) {
  while (b >= a) {
    int c = la[b + del];
    if (la[b + del] == b) {
      ans++;
      c--;
    }
    la[b + del] = a - 1;
    b = c;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = -10000010; i <= 10000010; i++) la[i + del] = i;
  for (int b = 1; b <= n; b++) {
    int l = -1, r = b;
    while (r - l > 1) {
      int mi = (l + r) / 2;
      if ((long long)b * b - (long long)mi * mi <= m)
        r = mi;
      else
        l = mi;
    }
    if (r == b) {
      ans += min((long long)b * b, (long long)m);
      ans += min((long long)b * b, (long long)m);
    } else {
      ans += min((long long)b * b, (long long)m) - ((b - 1) - r + 1);
      ans += min((long long)b * b, (long long)m) - ((b - 1) - r + 1);
      ins(-b - (b - 1), -b - r);
      ins(-b + r, -b + (b - 1));
    }
  }
  cout << ans << endl;
}
