Smart Strategy

Steve and Digit bought a box containing a number of cookies. In order to divide the cookies among themselves they decided to play a special game they invented. The players alternately take a certain, positive number of cookies from the box, but no more than a fixed integer. Each player’s cookies are gathered on the player’s side. The player that empties the box eats his cookies while the other one puts his cookies back into the box and the game continues with the “looser” player starting first. The game goes on until all the cookies are eaten. The goal of the game is to eat the most cookies. How many cookies can Steve, who starts the game, count on, assuming the best strategy for both players? Your task consists of writing a program that: • reads the parameters of the game from the standard input, • computes the number of cookies that Steve can count on, • writes the result to the standard output. Input The input file contains several test cases, each of them as described below. The first and only line contains exactly two integers n and m separated by a single space, 1 ≤ m ≤ n ≤ 100 — parameters of the game, where n is the number of cookies in the box at the beginning of the game and m is the upper limit on the number of cookies to be taken by one player in one move. Output For each test case, the output contains exactly one integer equal to the number of cookies that Steve can count on, on a line by itself. Sample Input 52 100 34 Sample Output 3 66