H, A = map(int, input().split()) def fight(h, A, cnt): if h == 1: return 1 else: return 1 + 2 * fight(h // A, A, cnt + 1) print(fight(H, A, 1))