

def main():
    a,b = raw_input().split(" ")
    a,b = int(a),int(b)
    
    r = 0
    total = 0
    while a != 0:
        total += a
        r += a
        
        a = r / b
        r -= a*b
        
        if a == 0:
            print total
            return
        
main()