So,
If the ratio of cats to dogs in the room is 2:3, that means that there are 2 cats per each 3 dogs.
Notice the following sequence:
Initial:
Cats: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34
Dogs: 3 6 9 12 15 18 21 24 27 30 33
After 5 more cats, the ratio is:
Cats: 0 9 18 27 36
Dogs: 0 11 22 33 44
We look for the situation where the number of dogs is the same and there are 5 more cats.
Therefore, there were 22 cats and 33 dogs at the beginning.