Aunt Polly is baking muffins at a speed of 4 muffins per minute. Tom comes into the kitchen when Aunt Polly has 12 muffins, and begins to eat these muffins at a speed of 6 muffins per minute. When he finally leaves the kitchen, there are 4 muffins at the table. How long did Tom stay in the kitchen?