#!/usr/local/bin/python
import math
a, b = map(int, raw_input().split())

res = a
out = a

while (out >= b):
	a = out / b;
	out = out % b;
	res = res + a;
	out = out + a;

print res

#raw_input("Press ENTER to exit")