Let t be how many he kept, r how many he gave to Ryan and n how many he gave to Neil.
The total have to still be 47, so:
[tex]t+r+n=47[/tex]If he gave Neil 3 less than Ryan, than the number he gave to Neil plus 3 will be the number he gave to Ryan, so:
[tex]n+3=r[/tex]And if he kept 5 mre than Ryan, the number he kept is equal the number he gave Ryan plus 5:
[tex]t=r+5[/tex]Since we want to know the number he kept, t, we can substitute the other variables so that we have an equation with only the variable t.
So, since r is in all equations, let's first solve the second for n and substitute it into the first, which will reduce the system to only 2 variables:
[tex]\begin{gathered} n+3=r \\ n=r-3 \end{gathered}[/tex][tex]\begin{gathered} t+r+n=47 \\ t+r+r-3=47 \\ t+2r=50 \end{gathered}[/tex]Now, we can solve the third equation for r and substitute it into the above one:
[tex]\begin{gathered} t=r+5 \\ r=t-5 \end{gathered}[/tex][tex]\begin{gathered} t+2r=50 \\ t+2(t-5)=50 \\ t+2t-10=50 \\ 3t=60 \\ t=\frac{60}{3} \\ t=20 \end{gathered}[/tex]So, Tom kept 20 for himself.