z = [int(i) for i in input().split()]
a = z[0]
b = z[1]
result = a 
add = 0  
def candles(a):
    global result 
    global add
    add = 0 
    while(a>0 and a>=b):

        a = a -b 
        add = add + 1 
    result = result + add    
    if (add >= b ):
        candles(add)    
    return result
print(candles(a))
9f8f385455aace3ee608ea8a6fa38d502e98e9cb
<mask token>

<mask token>


def candles(a):
    global result
    global add
    add = 0
    while a > 0 and a >= b:
        a = a - b
        add = add + 1
    result = result + add
    if add >= b:
        candles(add)
    return result


<mask token>

<mask token>


def candles(a):
    global result
    global add
    add = 0
    while a > 0 and a >= b:
        a = a - b
        add = add + 1
    result = result + add
    if add >= b:
        candles(add)
    return result


print(candles(a))

z = [int(i) for i in input().split()]
a = z[0]
b = z[1]
result = a
add = 0


def candles(a):
    global result
    global add
    add = 0
    while a > 0 and a >= b:
        a = a - b
        add = add + 1
    result = result + add
    if add >= b:
        candles(add)
    return result


print(candles(a))

z = [int(i) for i in input().split()]
a = z[0]
b = z[1]
result = a 
add = 0  
def candles(a):
    global result 
    global add
    add = 0 
    while(a>0 and a>=b):

        a = a -b 
        add = add + 1 
    result = result + add    
    if (add >= b ):
        candles(add)    
    return result
print(candles(a))