import sys

used, shrinkconst = map(int, sys.stdin.readline().split())
unused = 0

count = used

while used != 0:
    unused = unused + used % shrinkconst
    used = used / shrinkconst + unused / shrinkconst
    unused %= shrinkconst
    count += used

print count

					 	 			 	 					  	 		