Solution (source code)

= Solution

Apply the <law of iterated expectation> to the auxiliary <binomial distribution>:
$$
\boxed{\mathbb E[X]=\mathbb E[\mathbb E[X\mid p_M]]=n\mathbb E[p_M]=\frac{n\alpha}{\alpha+\beta}.}
$$
This expectation is over the full <prior distribution> construction, not over a particular observed auxiliary count.