Since in three years the sum of their ages will be 54, the sum of their ages now is 54 - 2*3 = 48 years. So, Mary is twice as old as Kim and the sum of their ages now is 48 years. Hence, Mary is 32 years, while Kim is 16 years old.