(1) A gambler wins each game with probability p. In each of the following cases, determine the expected total number of wins.

(a) The gambler will play n games; if he wins X of these games, then he will play an additional X games before stopping.

(b) The gambler will play until he wins; if it takes him Y games to get this win, then he will play an additional Y games.

I'm having some trouble wrapping my head around this one.

So far, for part A I'm looking at it like this

E[W]=E[W|wins X games]P(wins X games)

That line of thinking gets me