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:
![t+r+n=47](https://img.qammunity.org/2023/formulas/mathematics/college/qksy4dwtoseykzvs0x9u4zjq0od434lwhh.png)
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:
![n+3=r](https://img.qammunity.org/2023/formulas/mathematics/college/bjhj2p4ing4i32x212s6bwhhej0491uzwv.png)
And if he kept 5 mre than Ryan, the number he kept is equal the number he gave Ryan plus 5:
![t=r+5](https://img.qammunity.org/2023/formulas/mathematics/college/3jwh0ijv1y9nulkzmb6rknzsawnwookphk.png)
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:
![\begin{gathered} n+3=r \\ n=r-3 \end{gathered}](https://img.qammunity.org/2023/formulas/mathematics/college/fzdqumbtmmtttpe68bcikb776i7wmtb9gs.png)
![\begin{gathered} t+r+n=47 \\ t+r+r-3=47 \\ t+2r=50 \end{gathered}](https://img.qammunity.org/2023/formulas/mathematics/college/db5nmg37wjx75okaeg01ljhxviizbhrczk.png)
Now, we can solve the third equation for r and substitute it into the above one:
![\begin{gathered} t=r+5 \\ r=t-5 \end{gathered}](https://img.qammunity.org/2023/formulas/mathematics/college/kf47rtj97hqb8864ueqevjk5xy9r6qvu5x.png)
![\begin{gathered} t+2r=50 \\ t+2(t-5)=50 \\ t+2t-10=50 \\ 3t=60 \\ t=(60)/(3) \\ t=20 \end{gathered}](https://img.qammunity.org/2023/formulas/mathematics/college/h4ech35mdw6cx7wfd7x1fwrj1r0wgqdn6a.png)
So, Tom kept 20 for himself.