# import sys
#
# sys.stdin = open('input.txt')
# sys.stdout = open('out.txt', 'w')

a, b = map(int, raw_input().split())
c = 0
r = 0
while a > 0:
    r += a
    c += a
    a = c // b
    c = c % b
print r
