from functools import lru_cache

H, A = map(int, input().split())


@lru_cache(maxsize=None)
def f(h):
    if h == 0: return 0
    x = h // A
    return f(x) + f(x) + 1


ans = f(H)
print(ans)