The number of coins in Tom's collection is 3 more than a multiple of 6 and also 7 more than a multiple of 8. The smallest numbers that satisfies both conditions is 15. The lowest common multiple of 6 and 8 is 24, so the conditions will also be met by numbers that exceed 15 by a multiple of 24, that is 39, 63, 87, etc. So when Tom puts his coins in piles of 24, 15 remain.
This problem is taken from the UKMT Mathematical Challenges.