Nick had cupcakes and Valen had scones. Both gave half of what they had to each other. Nick sold 15 cupcakes and Valen sold 24 scones. In the end, the ratios of cupcakes to scones for Nick and Valen were 1 : 4 and 1 : 2 respectively. How many cupcakes did Nick have at first?