a,b = map(int,raw_input().split())

c = 0
u = 0

while a != 0 and u < b :
    c += a
    
    u += a % b
    a = a/b
    
    
    if u >= b:
        a += u/b
        u = u%b
        
        
    
    
print c