a, b = map(int, raw_input().split())
hoursLit = a
spentCandles = a
while(spentCandles >= b):
    newCandles = spentCandles / b
    spentCandles -= newCandles * b
    hoursLit += newCandles
    spentCandles += newCandles
print hoursLit
