War has broken out in the kingdom. The king's castle is guarded pretty heavily, by guards with instructions to kill anyone who can't produce the correct password.
Unbeknownst to the guards, the beggars near the main gate are in fact enemy spies. They listen intently as the first knight approaches. "Six!", the guard calls out. "Three," answers the knight. He is allowed through. "Aha," the spies think.
But they needs to be sure. They see another knight approaching and listen in on his exchange with the guard. "Twelve!", "Six!"
One spy decides he's heard enough, so he leaves and returns dressed as a knight. "Eighteen!" The spy answers "nine" and is killed on the spot by the guards.
Another spy, who used to browse Puzzling.SE before he signed up for the Espionage Division feels a moment of deja vu, and decides he now knows the answer. As night falls, he goes off and disguises himself as a knight. He comes back in the morning and walks up to the guard.
"Eighteen!" shouts the guard, "Eight!" the spy replies. The guard cuts him down, and he makes a surprised "gurgle...splot" noise as he dies.
The last spy, still in hiding is confused. As he's thinking, another knights walks up. "Twelve!" is the challenge, "Zero!" comes the reply. The guard steps aside and the knight enters.
Finally, the last spy gets up, goes off and does the whole dress-as-a-knight thing and comes back. "Eighteen!" shouts the guard. What is the correct response?
Update: The answer to TWELVE could have been Zero or Six either time - both were correct. This is one of only two such cases of 2 valid answers.
Edit for anyone who sees this in the future: I'm aware that it's not fully-scoped. It's my first puzzle and I neglected to give any odd-number examples, which is kind of important. It's totally solvable without them, I just should have included at least one.