Riordan had cupcakes and Sean had scones. Both gave half of what they had to each other. Riordan sold 14 cupcakes and Sean sold 24 scones. In the end, the ratios of cupcakes to scones for Riordan and Sean were 1 : 7 and 1 : 5 respectively. How many cupcakes did Riordan have at first?