#include <bits/stdc++.h>
char hash[20000001] = {0};
int main() {
  long i, j, n, m;
  long long ans = 0;
  scanf("%ld%ld", &n, &m);
  for (i = 1; i <= n; i++) {
    ans += 2 * (((long long)i * i) < (m) ? ((long long)i * i) : (m));
    for (j = i - 1; j >= 0 && (long long)i * i - (long long)j * j <= m; j--) {
      ans -= hash[10000000 - i + j];
      hash[10000000 - i + j] = 1;
      ans -= hash[10000000 - i - j];
      hash[10000000 - i - j] = 1;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
