The pirate made 3 stacks of gold coins.
Stack 1. 12 coins
Stack 2. 15 coins (3 coins taller than the #1)
Stack 3. 8 coins (7 coins shorter than the #2)

so 12 + 15 + 8 = 35 coins.

the answer is : 35