#K34682. Nim Game Winning Strategy

    ID: 25364 Type: Default 1000ms 256MiB

Nim Game Winning Strategy

Nim Game Winning Strategy

You are given a variation of the classic Nim Game. Initially, there are n objects in a heap. Two players take turns removing between 1 and k objects from the heap. The player who removes the last object wins the game.

The winning strategy is based on the observation that if

$$n \bmod (k+1) = 0$$

then the second player has a winning strategy (assuming both play optimally). Otherwise, the first player wins.

Your task is to determine which player has a winning strategy, given the two integers n and k.

inputFormat

The input consists of a single line containing two space-separated integers: n (the initial number of objects) and k (the maximum number of objects that can be removed in one turn).

outputFormat

Output a single integer: output 1 if the first player has a winning strategy, and 2 if the second player has a winning strategy.## sample

10 3
1