a,b=[int(i) for i in raw_input().split()]
def converted(material,b):
	lite=material/b
	rem=material%b
	return [lite,rem]
	
t=a
sum=0
rem=0
burnt=0
while t>0:
	sum+=t
	burnt=t
	t,rem=converted(burnt+rem,b)
	#print rem,burned,t
print sum
	