A man picks apples. On his way to town, he has to pass seven gates. At each gate stands a guardian. Claiming half of the apples and one apple extra. At the end, the man has only one apple left. How many apples did he have at the beginning?