5 3
 1000 3
 777 17
 4 3
 2 2
 100 4
 10 4
 999 2
 6 4
 1 2
 17 3
 1 4
 26 8
 91 5
 1 3
 1000 2
 20 3
 9 4
 123 5
 1000 1000
 3 2
 3 3
 80 970
 1000 4
 1 1000

7
 1499
 825
 5
 3
 133
 13
 1997
 7
 1
 25
 1
 29
 113
 1
 1999
 29
 11
 153
 1001
 5
 4
 80
 1333
 1

from __future__ import division
from collections import Counter as ctr
from math import ceil, log, factorial, sqrt
# reads a line of input and converts into a list of ints
# 1 1 3 => [1, 1, 3]
def rl():
    return [int(i) for i in raw_input().split()]

# reads n lines of input (if n defined) and returns a list of strings
# where each element is a line in the input
# abc
# abcdef
# => ['abc', 'abcdef']
# if n not defined, read first line to get number of lines
# 2
# abc
# abcdef
# => ['abc', 'abcdef']
def rm(n=None):
    if n is None:
        n = input()
    return [raw_input() for i in range(n)]

# same as rm, except converts each line to a list of ints like rl
def rlm(n=None):
    if n is None:
        n = input()
    return [rl() for i in range(n)]

def yn(b):
    if b:
        print "YES"
    else:
        print "NO"

a, b = rl()

total = 0 
burned = 0
current = a
while True:
    total += current
    burned += current
    current = 0
    current = burned // b
    burned %= b
    if current < b:
        break

print total + current