from __future__ import print_function
def findout(a,b):
    if b>a:
	return a
    if b<=1:
	raise ValueError
    hours = 0	
    rems = a
    surplus = 0
    while(True):
	hours +=rems
	#print(rems,surplus,hours)	
	if rems+surplus<=b:
	    break
	rems +=surplus	
	surplus = rems%b
	rems = (rems)/b
	
	
    #print(rems)
    return hours+1 if rems==b else hours+1 if rems+surplus==b else hours

ab = list(map(int, raw_input().strip().split(" ")[:2]))
print(findout(ab[0],ab[-1]))