import sys

for line in sys.stdin:
    a = line.split()
    i = 1
    while i * 2 < int(a[0]) + 1:
        i = i * 2
    print(i-1)

数学角度思考,从前往后找