h = int(eval(input()))

p = 1

i = 1



while h > 1:

    h = h // 2

    p += 2 ** i

    i += 1



print(p)
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()))
p = 1
i = 1
while h > 1:
    h = h // 2
    p += 2**i
    i += 1
print(p)

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

-p = 1 +ans = 1 -    p += 2**i +    ans += 2**i -print(p) +print(ans)