A bakery sells muffins and cupcakes. Each muffin costs $2, and each cupcake costs $3. If you buy a total of 5 baked goods and spend $14, how many muffins did you buy?