Let x = the number of 3 hour classes. Since there were 42 classes in total, the number of 5 hour classes is 42-x. The cost of a 3 hour class is (3 hours)*($29) = $87. The cost of the 5 hour class is 5*$29 = $145.
$4466 = x*($87) + (42-x)*($145)
$4466 = 87x + 6090 - 145x
-$1624 = -58x
Solve for x, the number of 3 hour classes. Once you have x, the number of 5 hour classes is 42-x.