a = raw_input().split()
ini_candle, b = int(a[0]), int(a[1])
hour = 0
candle = ini_candle
burnt = 0
while candle > 0:
    hour += candle
    burnt += candle
    candle = 0
    candle += burnt/b
    burnt = burnt%b

print hour