Allen started out with x marbles. He doubled his number of marbles by buying an additional x marbles from Betty. Then he gave away one-third of all his marbles to his friend Clarence. At the end of the day, he had 16 marbles. How many marbles did he start out with