Artificial intelligent assistant

What is the probability that the gambler is ruined$?$ A gambler has one rupee in his pocket.He tosses an unbiased normal coin unless either he is ruined or unless the coin has been tossed for a maximum of five times.If for each head he wins a rupee and for each tail he looses a rupee,then what is the probability that the gambler is ruined$?$ I made the sample space $S=\left\\{H,T,HH,HT,HHH,HHT,HTH,HTT,HHHH,HHTH,HHHT,HHTT,HTHH,HTHT,HHHHH,HHHHT,HHTHH,HHHTH,HHHTT,HHTHT,HHTTH,HHTTT,HTHHH,HTHHT,HTHTH,HTHTT\right\\}$ Now the cases when he is ruined are $T,HHTTT,HTT,HTHTT$ So i calculated probability that the gambler is ruined=$\frac{4}{26}$.But the book answer is $\frac{22}{32}$ What is wrong in my solution.What is the right way to solve this problem?

Some of your outcomes will never happen. He can't get a H and then quit, nor would he quit after HTH, etc. And your samples are not all equally likely to happen. HHHTH for example will occur only 1 in 32 times, whereas HTT will occur 1 in 8 times, etc.

consider the ways he can be ruined and calculate those probabilities.

T has a 1/2 probability. HHTTT has a 1/32 prob,HTT has a 1/8 and HTHTT has 1 1/32. The probability is 1/2 + 1/32 + 1/8 + 1/32 is 22/32.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 5870ba0e50ce01f729163304c8b73bce