#include <bits/stdc++.h>
using namespace std;
int n, m;
struct Nodes {
  int l, r;
} p[500010];
int main() {
  int i, j, k;
  int b, c;
  long long res;
  while (scanf("%d%d", &n, &m) != EOF) {
    int lx[2], rx[2], ly[2], ry[2];
    res = 0;
    lx[0] = 100000000;
    ry[0] = -100000000;
    for (b = 1; b <= n; b++) {
      c = min((long long)b * b, (long long)m);
      int nowl, nowr;
      nowr = floor(sqrt((double)b * b - 1));
      nowl = ceil(sqrt((double)b * b - c));
      res += c;
      if (nowl <= nowr) {
        res -= nowr - nowl + 1;
        lx[1] = -b - nowr;
        rx[1] = -b - nowl;
        if (rx[1] >= lx[0]) rx[1] = lx[0] - 1;
        if (rx[1] >= lx[1]) {
          res += rx[1] - lx[1] + 1;
        }
        lx[0] = lx[1];
        rx[0] = rx[1];
      }
      res += c;
      if (nowl <= nowr) {
        res -= nowr - nowl + 1;
        ly[1] = -b + nowl;
        ry[1] = -b + nowr;
        if (ly[1] <= ry[0]) ly[1] = ry[0] + 1;
        if (ry[1] >= ly[1]) {
          res += ry[1] - ly[1] + 1;
          if (rx[0] == ly[1]) res--;
        }
        ly[0] = ly[1];
        ry[0] = ry[1];
      }
      if (c == b * b) {
      }
    }
    cout << res << endl;
  }
  return 0;
}
