Daniel brought a total of 39 pens and pencils and he spent a total of $91. If pencils cost two dollars each and pens cost three dollars each how many of each did he buy