In order to make a necklace, Alicia purchased a bag of 80 beads for a total of $39. Some of the beads were sterling silver and cost $.40 each, and the rest were gemstone beads that cost $.65 each. How many of each type of bead were in the bag? Please show your work!