H, A = map(int, input().split()) a = 0 c = 1 while H > 0: a += c c *= 2 H //= A print(a)