Setting

Peter has n cigarettes. He smokes them one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette. How many cigarettes can Peter have?

Input

Input is a sequence of lines. Each line contains two integer numbers giving the values of n and k. The input is terminated by end of file.

Output

For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.

Sample Input

4 3
10 3
100 5

Sample Output

5
14
124

This challenge is provided by the ACM International Collegiate Programming Contest.

Upload Solution

Please log in to submit your solution.

Statistics

Difficulty (6 votes)
Average test runtime 0.22
Points (changes over time) 10
Tried by 21 users
Solved by 18 users

Global ranking

# Name Runtime Points worth
1 Justin 0.13 15
2 Brian 0.13 15
3 ,s/java/NaN/gi 0.13 15
4 Daniel 0.14 14
5 mascent 0.15 13
6 Dark 0.16 12
7 Pascal 0.16 12
8 Irfan 0.16 12
9 JB 0.19 10
10 Melf 0.21 9
11 Chris Danger 0.21 9
12 Phatti McButterpants 0.23 8
13 Finn-Lasse 0.27 7
14 Mac 0.27 7
15 Birger 0.30 6
16 Soeren 0.33 6
17 Nis 0.37 5
18 IeM 0.39 5