import sys

def candles(a, b):
    s = a
    rest = 0
    while a / b:
        rest += a % b
        a /= b
        s += a
        a += rest
        rest = 0
    return s


if __name__ == '__main__':
    line = sys.stdin.readline()
    a, b = line.split()
    print candles(int(a), int(b))