import sys

std_input = sys.stdin.readlines() 

num_of_candles=float(std_input[0].split()[0])
new_candle_size=float(std_input[0].split()[1])

num_hours=int(num_of_candles)

while num_of_candles >1 :
    num_of_candles=int(num_of_candles)/new_candle_size+num_of_candles%1
    num_hours+=int(num_of_candles)
    
    
print num_hours