Andy was on his way to a marble tournament when he met Bob. Andy's bag of marbles was heavy, so he gave Bob 1/2 of his marbles plus two. Then he met Alex and gave him 1/4 of his remaining marbles plus five. Just before arriving at the tournament, He met Emily and gave her 1/2 of the marbles he had left. When he got to the tournament, he had two marbles left. How many marbles did he start with?