H,A=map(int,input().split()) t=1 ans=0 while H!=0: H=H//A ans+=t t*=2 print(ans)