# -*- coding: utf-8 -*-

import sys


num1,num2 = map(int,sys.stdin.readline().split())
count = num1

while True:

    if num1/num2 == 0:
        break
    else:
        count += num1/num2
        num1 = num1%num2 + num1/num2

print count