H,A=map(int,input().split()) def solve(H): if H==0: return 0 return solve(H//A)*2+1 ans=solve(H) print(ans)