
v = []

v = map(int, raw_input().split(" "))

ans = 0
candles = v[0]
cost = v[1]

ans = ans + candles
remind = candles

while( remind >= cost):
    ans += remind / cost
    remind = int( remind / cost + remind % cost)
    #print "remind: " + str(remind)

print ans