N,D = map(int,input().split()) M = (N ** 2) * 2 + D + 1 left = [0] * M right = [0] * M for x in range(1, N + 1): for y in range(1, N + 1): left[x**2 + y**2] += 1 for w in range(1, N + 1): for z in range(1, N + 1): val = w**2 - z**2 + D if val <= 0: break right[val] += 1 ans = 0 for i in range(M): if left[i] > 0: ans += left[i] * right[i] print(ans)