Gary cashed a check from Joan for $30.25. Then he bought two magazines for $2.35 each, a book for $6.05, and a CD for $6.37. He had $24.85 left. How much money did he have before cashing the check?