a, b = map(int, raw_input().split())
total = 0
resto = 0
while (True):
    total = total + a
    a = a + resto
    resto = a % b
    a = a // b
    if(a + resto < b):
        break
total = total + a
print total
