Nim is a mathematical game for two players. It is a member of the class of games known as "impartial" i.e., those games where from any given position, the same moves are legal for both players. The rules of Nim are that you start with a number of piles of counters - three piles of 3, 4 and 5 counters is good for beginners - and the players take turns removing any number of counters from one pile. The winner is the player who takes the last counter. (In misere Nim, the winner is the player who forces his/her opponent to take the last counter.)

The strategy for winning Nim is to try to leave your opponent in a position where if you write the number of counters in each pile in binary and add without carrying, the sum of each column will be even. Here's an example of how you work this out with piles of 4, 5, and 6 counters:

   4    100
   5    101
   6   +110
        ---
        311
Here you have to change the parity of all the columns. One way to do this is to remove one counter from the pile of 4.