h = int(eval(input()))

ans = 1

i = 1

while h > 1:

    h = h // 2

    ans += 2 ** i

    i += 1

print(ans)
h = int(eval(input()))

ans = 0

i = 0

while h > 0:

    h = h // 2

    ans += 2 ** i

    i += 1

print(ans)
h = int(eval(input()))
ans = 1
i = 1
while h > 1:
    h = h // 2
    ans += 2**i
    i += 1
print(ans)

h = int(eval(input()))
ans = 0
i = 0
while h > 0:
    h = h // 2
    ans += 2**i
    i += 1
print(ans)

-ans = 1 -i = 1 -while h > 1: +ans = 0 +i = 0 +while h > 0: