word=raw_input()
lis=word.split()
burned_candles=int(lis[0])
how=int(lis[1])
hours=int(lis[0])
temp=0
x=0
while burned_candles>1:
    hours+=burned_candles/how
    if burned_candles>how:
        x=burned_candles%how
    else:
        break
    burned_candles=burned_candles/how
    burned_candles+=x
hours+=temp/how
print hours
    

    
