h, a = map(int, input().split()) ans = 0 cnt = 1 while h: ans += cnt cnt *= 2 h //= a print(ans)