Bryan had muffins and John had cupcakes. Both gave half of what they had to each other. Bryan sold 8 muffins and John sold 38 cupcakes. In the end, the ratios of muffins to cupcakes for Bryan and John were 1 : 7 and 1 : 5 respectively. How many muffins did Bryan have at first?