Sarah went shopping at Target. She bought a shirt for $12.99, a pair of shoes for $16.99, and a pair of sunglasses. How much did she spend on the sunglasses if she spent a total of $39.87?