#include <bits/stdc++.h>
using namespace std;
vector<double> vec;
long long ans = 0;
double arr[10000100];
long long p = 0;
bool cal(long long b1, long long c) {}
bool used[20000000];
int main() {
  long long M = 10000000;
  long long n, m, an = 0, i, j, x;
  cin >> n >> m;
  for (i = 1; i <= n && i * i <= m; i++) an += i * i * 2 - 1;
  an += (n - i + 1) * m * 2;
  for (i = 1; i <= n; i++) {
    for (j = i - 1; j >= 0; j--) {
      x = i * i - j * j;
      if (x <= m) {
        if (used[-i - j + M])
          an--;
        else
          used[M - i - j] = 1;
        if (j) {
          if (used[M - i + j])
            an--;
          else
            used[M - i + j];
        }
      } else
        break;
    }
  }
  cout << an << endl;
  return 0;
}
