#include <bits/stdc++.h>
using namespace std;
int minK[5000005];
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  vector<pair<int, int> > v;
  for (long long b = 1; b <= N; b++) {
    if (b * b <= M)
      minK[b] = 0;
    else {
      minK[b] = minK[b - 1];
      while ((b - minK[b]) * (b + minK[b]) > M) minK[b]++;
    }
    if (minK[b] < b) {
      v.push_back(pair<int, int>(-b - b + 1, 1));
      v.push_back(pair<int, int>(-b - minK[b] + 1, 0));
      v.push_back(pair<int, int>(-b + minK[b], 1));
      v.push_back(pair<int, int>(0, 0));
    }
  }
  sort(v.begin(), v.end());
  long long result = 0;
  int c = 0;
  for (int i = 0; i < v.size() - 1; i++) {
    if (v[i].second)
      c++;
    else
      c--;
    if (c) result += v[i + 1].first - v[i].first;
  }
  for (int i = 1; i <= N; i++) {
    result += 2 * min((long long)M, (long long)i * i);
    ;
    if (minK[i] < i) result -= 2 * (i - minK[i]);
  }
  printf("%I64d\n", result);
}
