def fun(x,y):
    ro=x
    rt=0
    while x>0:
        x+=rt
        s=x//y
        ro+=s
        rt=x%y
        x=s
    return ro
if __name__=='__main__':
    x,y=map(int,raw_input().strip().split())
    print fun(x,y)