input_ = raw_input()

a = int(input_.split(' ')[0])
b = int(input_.split(' ')[1])

max_light = 0
num_of_candles = a
num_of_leftover = 0
while num_of_candles > 0:
    max_light += num_of_candles
    num_of_leftover += num_of_candles%b
    num_of_candles = num_of_candles/b
    if num_of_leftover >= b:
        num_of_candles += num_of_leftover/b
        num_of_leftover = num_of_leftover%b

print max_light
