h=int(eval(input()))

i=0

ans=0

while h>0:

    ans+=(1<<i)

    h//=2

    i+=1

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

i=0

while h>0:

    h//=2

    i+=1

print(((1<<i)-1))

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

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

-ans = 0 -    ans += 1 << i -print(ans) +print(((1 << i) - 1))