N, D = map(int, input().split()) mx = 2 * pow(N, 2) def make_cnt(n, d=None): cnt = [0] * (mx + 1) for i in range(1, n+1): for j in range(1, n+1): if d is not None: tmp = pow(i, 2) - pow(j, 2) + d else: tmp = pow(i, 2) + pow(j, 2) if 0 < tmp < mx + 1: cnt[tmp] += 1 return cnt xy_cnt = make_cnt(N) wz_cnt = make_cnt(N, D) ans = 0 for i in range(1, mx+1): ans += xy_cnt[i] * wz_cnt[i] print(ans)