def candles(a, b):
    res = a
    rem = 0
    while a > 0:
        a += rem
        s = a // b
        res += s
        rem = a % b
        a = s
    return res



a, b = map(int, raw_input().strip().split())
print candles(a, b)