Daniel had muffins and Ryan had tarts. Both gave half of what they had to each other. Daniel sold 9 muffins and Ryan sold 22 tarts. In the end, the ratios of muffins to tarts for Daniel and Ryan were 1 : 8 and 1 : 6 respectively. How many muffins did Daniel have at first?