global k def f(x): s=x//k if s>=k: s+=f(s) return s else: return s n,k=map(int,input().split()) n=f(n)+n print(n)