[a, b] = map(int, raw_input().split())
went_out = 0
ans = 0
while True:
  if a > 0:
    ans += a
    went_out += a
    a = 0
  elif went_out >= b:
    a += went_out / b
    went_out = went_out % b
  else:
    break
print ans
