We interpret "wins two dollars" as meaning wins a net one dollar, because of the one dollar fee per trial. It follows that if we have $2$ or $4$ dollars, we are about to enter Casino $X$, and if we have $1$ or $3$ dollars we are about to enter $Y$.
Introduce $4$ variables $w_1,w_2,w_3,w_4$, where $w_k$ is the probability of ultimately ending up with $5$ dollars if we have $k$ dollars. We are only interested in $w_2$, but it is useful to consider all four.
Now we write down a bunch of transition equations. For example, if we have
$2$ dollars, we will either have a net gain of a dollar (probability $p_x$) or a net loss of a dollar (probability $1-p_x$). That gives the simple linear equation
More simply, if we have a dollar, and are therefore about to enter $Y$, we either lose, in which case we will never have $5$ dollars, or we can win. That gives equation
We end up with $4$ equations in $4$ unknowns. Solve. It is not hard, mechanical substitution will do it, since two of the equations are particularly simple.
Added: The equations are 1) $w_1=p_y w_2$; 2) $w_2=p_xw_3+(1-p_x)w_1$; 3) $w_3=p_y w_4+(1-p_y)w_2$; and finally 4) $w_4=p_x+(1-p_x)w_3$. The last equation holds because if we have $4$ dollars and win the next game, we end up with $5$ dollars for sure, while if we lose we have $3$ dollars left. If you like you can think of the $p_x$ as $p_x\cdot 1$.
Replace $w_1$ in Equation 2) by $p_yw_2$. Replace $w_4$ in Equation 3) by $p_x+(1-p_x)w_3$, and simplify. We end up with two linear equations in two unknowns $w_2$ and $w_3$. Solve in any of the usual ways. Life will be easier if you write $q_x$ for $1-p_x$ and $q_y$ for $1-p_y$.