def nis():
    return map(int, raw_input().split())

a, b = nis()

count = a
while True:
    candles = a / b
    if not candles:
        break
    rem = a % b
    count += candles
    a = candles + rem

print count
