#!/usr/local/bin/python

from sys import stdin

new_candles, needed = map(int, stdin.readline().split())

res = new_candles
used_candles = new_candles

while used_candles >= needed:
	new_candles = used_candles/needed
	res += new_candles
	left_unused_candles = used_candles % needed
	used_candles = new_candles + left_unused_candles

print res