A shop sells one-pound bags of peanuts for $2 and three-pound bags of peanuts for $5. If 9 bags are purchased for a total cost of $36, how many three-pound bags were purchased?

A. 18
B. 3
C. 9
D.6