H=int(eval(input()))

cnt=0

while H>0:

  cnt+=1

  H=H//2

print((2**cnt-1))
H = int(eval(input()))



cnt = 0

while H > 0:

    H //= 2

    cnt += 1

print((2**cnt-1))
H = int(eval(input()))
cnt = 0
while H > 0:
    cnt += 1
    H = H // 2
print((2**cnt - 1))

H = int(eval(input()))
cnt = 0
while H > 0:
    H //= 2
    cnt += 1
print((2**cnt - 1))

+    H //= 2 -    H = H // 2