1. 

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10346 Peter's Smokes
*
* @author Robert Reichart
*
* Status : Accepted
* Runtime: 0.144
*/

import java.util.*;
class Main{
public static void main(String... args){
Scanner in = new Scanner(System.in);
while (in.hasNextInt())
{
int n = in.nextInt();
int k = in.nextInt();
int total_cigar=0;
int butt=0;
while (n > 0) {
total_cigar += n; /* accumulate all new cigars so far */
butt += n; /* after Peter smokes these n cigar, we have n butts */
n = butt / k; /* so these n butts become new cigars */
butt %= k; /* butts left are reserved for future cigars */
}
System.out.println(total_cigar);
}
}
}