n = int(eval(input()))

res, i = 0, 1

while n > 0:

    res += i

    i *= 2

    n //= 2

print(res)

N = int(eval(input()))



q = N

cnt = 0



while (q > 1) :

    q = q // 2

    cnt += 1



print((2 ** (cnt + 1) - 1))
n = int(eval(input()))
res, i = 0, 1
while n > 0:
    res += i
    i *= 2
    n //= 2
print(res)

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

-n = int(eval(input())) -res, i = 0, 1 -while n > 0: -    res += i -    i *= 2 -    n //= 2 -print(res) +N = int(eval(input())) +q = N +cnt = 0 +while q > 1: +    q = q // 2 +    cnt += 1 +print((2 ** (cnt + 1) - 1))