When a bakery opened this morning the ratio of pineapple muffins to the number of mango muffins was 3:2. After 144 pineapple muffins were sold, the ratio of the number of pineapple muffins to the number of mango muffins changed to 3:5. How many pineapple muffins were there when the bakery opened in the morning?

Answer is 240, but we need ot know how to get to the answer.