string = raw_input()

numlist = string.split()
new = int(numlist[0])
b = int(numlist[1])
burnt = 0
hours = 0

while (new/b) >= 1:
    hours += new
    burnt += new
    new = burnt/b
    burnt = burnt%b
if (new/b == 0 and new > 0):
    hours += new
    burnt += new
    new = burnt/b
    hours += new
print hours