Assume that $p\ne 0$ and $p\ne 1$.
If we get a tail on the first toss (probability $1-p$), the expected number of heads is $1$. That is because in this case, the game stops as soon as we get a head.
If we get a head on the first toss, then we already have one head. The expected number of additional tosses until we get a tail is $\dfrac{1}{1-p}$. That is by the standard formula for the mean of a geometrically distributed random variable. All but one of these are additional tosses are heads.
So in that case the expected number of heads is $1+\dfrac{1}{1-p}-1=\dfrac{1}{1-p}$. Thus the required expectation is
$$(1-p)(1)+p\dfrac{1}{1-p}.$$
If we wish, we can simplify this to $\dfrac{1-p+p^2}{1-p}$. It may be a little prettier to multiply top and bottom by $1+p$, obtaining $\dfrac{1+p^3}{1-p^2}$.
Let $N$ denote the number of tosses until you see “TH” for the first time. Find $\mathsf E(N)$
In order to encounter the termination event we must toss a series of none or more heads, a series of one or more tails, and then one head. The pattern, $\mathsf{[T]_XH[H]_YT}$
Here $X$ and $Y$, the number of tosses of a given face before the opposite face have geometric distributions.
$$X,Y\sim \mathcal {Geom}(1/2) \implies \mathsf E(X) = \frac{1-1/2}{1/2}=\mathsf E(Y)$$
$$\mathsf E(N) = \mathsf E(X)+\mathsf E(Y) +2$$
Now let $M$ denote the number of tosses until we see “HH” for the first time.
In order to encounter the terminating event we toss none or more tails, a head then either another head (terminate) or a tail (then reiterate). The recursive pattern is $\mathsf{P:=[T]_ZH(H|T P)}$
Where $Z$ is again a geometrically distributed value.
$$\mathsf E[M]=\mathsf E[Z] + 2 + \tfrac12 \mathsf E[M]$$
Can you take it from here?
Best Answer
The answer is $70=2^{\color{red}{6}}+2^{\color{red}{2}}+2^{\color{red}{1}}$. The integers $6$, $2$ and $1$ are the lengthes of the prefixes of the word HHTTHH that are also its suffixes, here HHTTHH, HH and H.
For more details, see some previous posts on the site about this exact model, or the book DNA, Words and Models by Robin, Rodolphe, and Schbath (2005), or the survey Enumeration of strings (1985) by A. Odlyzko (see section 4, citing the paper A combinatorial identity and its application to the problem concerning the first occurrences of a rare event (1966) by A. D. Solov’ev).