H = int(eval(input()))



h = 0

while H != 1:

	H = int(H/2)

	h += 1

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



def f(x):

	if x == 1:

		return 1

	else:

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



print((f(H)))



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

H = int(eval(input()))


def f(x):
    if x == 1:
        return 1
    else:
        return 2 * f(int(x / 2)) + 1


print((f(H)))

-h = 0 -while H != 1: -    H = int(H / 2) -    h += 1 -print((2 ** (h + 1) - 1)) + + +def f(x): +    if x == 1: +        return 1 +    else: +        return 2 * f(int(x / 2)) + 1 + + +print((f(H)))