The question is: What did he have in the beginning ? All the information we have happened after that. So if we want to work through the information towards the answer, maybe it makes sense to solve it starting from the end, working backwards toward the beginning.
Manuel had 5 marbles left at the end of the story.
Those 5 remained after he gave Matt 2 . Before he gave Matt 2, he had 7 .
Those 7 remained after he gave Matt half of his marbles. Before he gave Matt half of his marbles, he had 14 .
Those 14 remained after he gave Lily 1 marble. Before he gave Lily 1 marble, he had 15 .
Those 15 remained after he gave Lily half of his marbles. Before he gave Lily half of his marbles, he had <em>30</em> .