Ivan had tarts and John had cupcakes. Both gave half of what they had to each other. Ivan sold 8 tarts and John sold 26 cupcakes. In the end, the ratios of tarts to cupcakes for Ivan and John were 1 : 6 and 1 : 4 respectively. How many tarts did Ivan have at first?