Problem J. Jolly evening

Author:Антон Карабанов   Time limit:1 sec
Input file:Standard input   Memory limit:512 Mb
Output file:Standard output  

Statement

Marina Tsvetaeva, Andrej Belyj and Sasha Chernyj are spending the evening playing chess. For each game two of them are playing and the third person is waiting to take the place of the loser. The winner of each game plays next game with white pieces.

After playing n games silver age poets were surprised to find out that white side had been repeatedly winning k times in a row, followed by a black victory every time.

Andrej Belyj likes to play with white pieces, Sasha Chernyj — with black, Marina Tsvetaeva likes either of the colors. Determine the number of games where both players played with the color they like. First game was between Andrej Belyj (played with white) and Sasha Chernyj (played with black). No game was a draw.

Input format

Two lines of input contain two integers n and k.

Output format

Output a single integer — problem answer.

Constraints

1 ≤ n ≤ 109

1 ≤ k ≤ 100

Notes on sample

4 games were played. White player had been winning one game, and then losing the next one.

In the first game Belyj — Chernyj both play the color they like. Andrej wins, playing with white.

In the second game Belyj — Tsvetaeva both play the color they like. Andrej loses, playing with white.

In the third game Tsvetaeva — Chernyj both play the color they like. Marina wins, playing with white.

In the final game Tsvetaeva — Belyj only Marina plays the color she likes. So the answer is 3 games.

Sample tests

No. Standard input Standard output
1
4
1
3

0.078s 0.010s 13