Ivan had cupcakes and Gabriel had shortbreads. Both gave half of what they had to each other. Ivan sold 10 cupcakes and Gabriel sold 34 shortbreads. In the end, the ratios of cupcakes to shortbreads for Ivan and Gabriel were 1 : 7 and 1 : 5 respectively. How many cupcakes did Ivan have at first?