This is a question about Example 14.1.13 from "A First Look at Rigorous Probability Theory" by Jeffrey Rosenthal, 2nd Edition. The example concerns an infinite fair coin tossing experiment, $\left \{r_n \right \}_{n \ge 1}$, with the $r_n$ having values 1 for heads and 0 for tails.
$\tau = \inf \left \{ n \ge 3: r_{n-2} = 1, r_{n-1} = 0, r_n = 1 \right \}$ is the first time the sequence heads, tails, heads appears.
The purpose of the example is to show how $E[\tau]$ can be computed using martingales. This is done as follows:
At each time $n$ a new player appears and bets \$1 on heads, if they win they bet \$2 on tails and if they win again they bet \$4 on heads. They stop betting if they either lose once or win three bets in a row. Let $S_n$ be they total amount won by all betters by time $n$. Then by construction $S_n$ is a martingale with stopping time $\tau$.
Once $S_n$ is shown to be a martingale the rest of the example is straightforward. However, I must be missing something obvious because I don't follow how $S_n$ as constructed is necessarily a martingale. I'm sure it's easy to see this and I've just missed/misunderstood something in how $S_n$ is constructed. Any pointers would be appreciated.