import itertools N, D = map(int, input().split()) sq = tuple(i ** 2 for i in range(1, N + 1)) xy, zw = [0] * (3 * N ** 2), [0] * (3 * N ** 2) for i, j in itertools.combinations(sq, 2): xy[i + j] += 2 zw[i - j] += 1 zw[j - i] += 1 for i in sq: xy[2 * i] += 1 zw[0] += N ans = 0 for i, a in enumerate(xy): ans += a * zw[i - D] print(ans)