H,a = map(int, input().split()) ans = 0 count = 1 while(1): if(H==0): break H = H//a ans+=count count*=2 print(ans)