import sys

#f = open('input.txt','r')
f = sys.stdin
a, b = map(int, f.readline().strip().split())

result = 0
rest = 0
while a >= b:
    result += a

    rest += a % b

    a = (a // b) + (rest // b)

    rest -= (rest // b) * b

print result + a + (rest + a % b) // b
