import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class NewYearCandles {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int sum = 0;
		if (a==b)
			System.out.println(a+1);
		else if (b>a)
			System.out.println(a);
		else{
			int rem = 0;
			while (a>0){
				sum+=a;
				rem+=a%b;
				a/=b;
			}
			while(rem>=b){
				sum+=rem/b;
				rem = rem%b + rem/b;
			}
			System.out.println(sum);
		}
	}
}
