import sys
class blowCandle(object):
    def __init__(self):
        self.line=sys.stdin.readline()
        self.data=self.line.strip("\n").split(" ")
        self.counter=0
        self.burn=0
        self.a=int(self.data[0])
        self.b=int(self.data[1])
    def doTheJob(self):
        poop=True
        while poop==True:
            self.counter+=self.a
            self.burn+=self.a
            self.a=0
            if self.burn <self.b:
                poop= False
            else:
                while self.burn > (self.b-1):
                    self.burn -= self.b
                    self.a += 1
        print self.counter

mine= blowCandle()
mine.doTheJob()
