import math H,A=map(int,input().split()) ans=0 i=0 while H>0: ans+=2**i H=math.floor(H/A) i+=1 print(ans)