H, A = [int(x) for x in input().split()] slimes = {H: 1} ans = 0 nxt = {} while slimes: for s in slimes: at = s // A if at > 0: if at not in nxt: nxt[at] = 0 nxt[at] += slimes[s] * 2 ans += slimes[s]