import sys

a,b = [int (x) for x in sys.stdin.readline().split()]
count = a
ys = 0

for i in range(a+b):
    if a>=b:
        ys = a%b
        a = int(a/b)
        count +=a
        a = a + ys
        i+=1
print count
