import math

def main():
    input = raw_input();
    input_list = input.split(' ')
    numbers = [float(x.strip()) for x in input_list]
    x = numbers[0]
    y1 = numbers[1]
    y = y1
    sum = x
    bool = True
    while bool:
        z = x/y
        if z >= 1:
            sum += int(z)
            #y = y*y1
            x = int(z) + x%y
            #print sum, z, x, y
        elif z < 1:
            bool = False
    print int(sum)


if __name__ == "__main__":
    main()
