n, D = map(int, input().split()) lim = 10 ** 8 base = lim // 2 res = [0] * lim for i in range(1, n + 1): for j in range(1, n + 1): res[i ** 2 + j ** 2 + base] += 1 cnt = 0 for i in range(1, n + 1): for j in range(1, n + 1): d = D - i ** 2 + j ** 2 cnt += res[base + d] print(cnt)