Let's denote their ages by the first letter of their names.
The first sentence says that $(E-5)=3(A-5)$
The second sentence says $E+3=2(A+3)$
You can solve these to find that $A=13$ and $E=29$
As a check, five years ago they were $8$ and $24$, and in three years they will be $16$ and $32$, as desired.
You will always have two unknown constants to solve for, since that is what the question asks for. If you are trying to solve using only the unknown "the sum of their ages" then you will have a bad time, since the problem only gives you information about their individual ages.