from sys import stdin


def main():
    a, b = map(int, stdin.readline().rstrip().split())
    candle_burnt = a
    while(a >= b):
        candle_burnt += a / b
        a = (a - (a / b) * b) + a / b
        # print a
    print candle_burnt


if __name__ == '__main__':
    main()
