r = raw_input()
l = r.split(' ')
new = int(l[0])
rate = int(l[1])
left = 0
ash = 0
total = 0

while new+left >= rate:
    total = total+new
    ash = left+new
    used = (ash/rate)*rate
    left = left+new-used
    new = used/rate

    
total = total+new
print total
