You are on your way to your friend's house. You decide to carry 2 apples to your friend. To get to their house, you must pass across 8 gates. At each gate, the keeper will take half the amount of apples you have and return one apple back. The question is, how many apples should you carry at the beginning?