A store sells pencils at a rate of $0.50 each and erasers at $0.75 each. If Tom buys a total of 12 items, consisting of pencils and erasers, and spends $7.50, how many pencils did he buy?