Two players play a game with two piles of stones. They take alternating turns. If there are currently stones in the first pile and stones in the second, a turn consists of removing stones from the first pile and from the second in such a way that . The winner is the player who first empties one of the piles.
Note that the game is only playable if the sizes of the two piles are coprime.
A game state is a winning position if the next player can guarantee a win with optimal play. Define to be the number of winning positions with , , and . Note the order matters, so for example and are distinct positions.