hp = int(eval(input()))

if hp == 0:

    print((1))

    exit()



attack = 0

monster = 1

p = 1



for i in range(999):

    if hp == 0:

        break

    else:

        attack += 1

        hp = hp // 2



print((2 ** attack - 1)) 
hp = int(eval(input()))

attack = 0

monster = 1

p = 1



for i in range(999):

    if hp == 0:

        break

    else:

        attack += 1

        hp = hp // 2



print((2 ** attack - 1)) 
hp = int(eval(input()))
if hp == 0:
    print((1))
    exit()
attack = 0
monster = 1
p = 1
for i in range(999):
    if hp == 0:
        break
    else:
        attack += 1
        hp = hp // 2
print((2**attack - 1))

hp = int(eval(input()))
attack = 0
monster = 1
p = 1
for i in range(999):
    if hp == 0:
        break
    else:
        attack += 1
        hp = hp // 2
print((2**attack - 1))

-if hp == 0: -    print((1)) -    exit()