import math

H = int(eval(input()))

i = 1

if H == 1:

    print((1))

else:

    while H > 1:

        i = i + 1

        H = math.floor(H / 2)

    print((2 ** i - 1))

H = int(eval(input()))





def f(X):

    if X < 2:

        return X

    return f(int(X / 2)) * 2 + 1





print((f(H)))

import math

H = int(eval(input()))
i = 1
if H == 1:
    print((1))
else:
    while H > 1:
        i = i + 1
        H = math.floor(H / 2)
    print((2**i - 1))

H = int(eval(input()))


def f(X):
    if X < 2:
        return X
    return f(int(X / 2)) * 2 + 1


print((f(H)))

-import math +H = int(eval(input())) -H = int(eval(input())) -i = 1 -if H == 1: -    print((1)) -else: -    while H > 1: -        i = i + 1 -        H = math.floor(H / 2) -    print((2**i - 1)) + +def f(X): +    if X < 2: +        return X +    return f(int(X / 2)) * 2 + 1 + + +print((f(H)))