Out of 40 coins, 16 are dimes. Half of the remaining coins are quarters and the rest are pennies and nickels. There are 2 nickels for every penny. How many pennies are there?