h = int(eval(input()))



i = 0

ans = 1

while h:

    h = h // 2

    i += 1

for _ in range(1, i):

    ans = 2 * ans + 1

print(ans)

import math

h = int(eval(input()))

print((2**(math.floor(math.log2(h))+1)-1))

h = int(eval(input()))
i = 0
ans = 1
while h:
    h = h // 2
    i += 1
for _ in range(1, i):
    ans = 2 * ans + 1
print(ans)

import math

h = int(eval(input()))
print((2 ** (math.floor(math.log2(h)) + 1) - 1))

+import math + -i = 0 -ans = 1 -while h: -    h = h // 2 -    i += 1 -for _ in range(1, i): -    ans = 2 * ans + 1 -print(ans) +print((2 ** (math.floor(math.log2(h)) + 1) - 1))