A rare coin is repeatedly tossed, where $P(H)=p=1-q$. Let X be the number of spins until HTH appears for the first time, and Y the number of spins until HTH or THT appears. Prove that $$\mathbb{E}(t^X)=\frac{p^2qt^3}{1-t+pqt^2-pq^2t^3}.$$ Calculate $\mathbb{E}(t^Y)$.
I've been dealing with this problem all afternoon and I can't get to any results, so I turn to you for help. Any suggestion will be welcome. Thank you.