A bakery sells muffins and cookies. Each muffin costs $3 and each cookie costs $2. If a customer buys a total of 12 items consisting of muffins and cookies, and spends a total of $30, how many muffins did the customer buy?