Xavier had cookies and Henry had puffs. Both gave half of what they had to each other. Xavier sold 12 cookies and Henry sold 20 puffs. In the end, the ratios of cookies to puffs for Xavier and Henry were 1 : 4 and 1 : 2 respectively. How many cookies did Xavier have at first?