Find the expectation and standard deviation of the combined mass of rock samples collected

NASA plans to send a new rover to Mars. The rover will collect some rock samples and send them back to Earth on a small rocket. Due to energy limitations, the rover will make 9 attempts to collect a rock sample. Each attempt will have 70% chance of success. If an attempt is not successful, no rock will be deposited in the container on that attempt. The average mass of a single rock sample will be 10 grams, with a standard deviation of 2 grams (on a single successful attempt). Find the expected value and standard deviation of the combined mass of rock samples collected by the rover in all attempts.

My Attempt

Let $X$ denote the grams of rock collected per attempt. Then we are given that $E(X)=10$ and $Var(X)=SD^2=2^2=4$. Then let $Y$ denote the number of successful attempts (Notice that $Y$ has a binomial distribution). Then $E(Y)=np=9*0.7=6.3$. Now let $M$ denote the total mass of rock collected. Then we have $$E(M)=E(Y)E(X)=6.3*10=63$$

I am having trouble with finding the variance of $M$ so I could find the standard deviation. I looked at the solution for this part but I do not understand what formula they used for the variance. The solution is below. Could I get some clarification on which formula to use or if there is a different way of doing it? Thank you. enter image description here


It's the law of total variance with conditioning on $N$.

$$\text{Var}(M) = E[\text{Var}(M \mid N)] + \text{Var}(E[M \mid N]).$$

Conditioning on $N$, you can show $E[M \mid N] = NE[X_1]$; this will help with the second term above. Similarly, $\text{Var}(M \mid N) = N \text{Var}(X_1)$ because the $X_i$ are independent; this will help with the first term above.