'''
Created on Dec 30, 2013

@author: JASHAN GOYAL
'''
def r(a,b,d,e):
    
    if(a<b):
        d+=(a)
        return d
    elif a==b:
        d=d+1+a
        return d
    d=d+a-a%b
    e=a%b
    a=a/b+a%b
    return r(a,pow(b,1),d,e)


a,b=map(int,raw_input().split())
print r(a,b,0,a%b)