Keep tossing a coin until we have a total of $r$ heads (successes).

How likely to have $k$ tails (failures) before we stop?

$$
p(k) = {k+r-1 \choose k}\cdot (1-p)^r p^k
\\[16pt]
\text{where $r$ is the number of successes,}\\
\text{and $p$ is the probability of success.}
$$