ri = lambda: raw_input().strip()

a, b = map( int, ri().split())

total = 0

total += a
remains = a / b
notUse = a % b

#print remains, notUse

while remains > 0:
    total += remains
    tmp = (remains + notUse)
    remains = tmp / b
    notUse = tmp % b
    #print total, remains, notUse

print total;