A farmer in ancient Persia drove his cattle to pay tribute to the king. He had to go through 8 palace gates to get to the king. The gatekeeper at each place left half of the cattle he drove and returned one cow to him. After the Taoist gate, the farmer only has three cows left. Do you know how many cows the farmer drove away?
古波斯国的一位农民赶着牛群去给国王进贡，到国王那儿一共要过8道宫门，每处看门人都将所赶的牛留下一半，再归还他一头牛，过完四道门后，农民只剩下三头牛了，你知道农民原来赶了多少头牛吗？
<gadget id="calculator">3 - 1</gadget>
<output>2</output>

<gadget id="calculator">2 * 2</gadget>
<output>4</output>

<gadget id="calculator">4 - 1</gadget>
<output>3</output>

<gadget id="calculator">3 * 2</gadget>
<output>6</output>

<gadget id="calculator">6 - 1</gadget>
<output>5</output>

<gadget id="calculator">5 * 2</gadget>
<output>10</output>

<gadget id="calculator">10 - 1</gadget>
<output>9</output>

<gadget id="calculator">9 * 2</gadget>
<output>18</output>

<result>18</result>