h, a = [int(x) for x in input().split()] ans = 0 cnt = 1 while True: ans += cnt h //= a cnt *= 2 if h == 0: break print(ans)