# Name :A. New Year Candles
# N0# 379
# Contest# Good Bye 2013
# Division:

(a,b) = map(int, raw_input().split())
res = a
rem = 0
while (a):
    rem += a % b
    a /= b
    if( rem >= b):
        a += 1
        rem %= b
    res += a

print res