H = int(eval(input()))



ans = 1



if H == 1:

    print((1))

    exit()



while True:

    tmp = ans*2 + 1

    if H > ans and H <= tmp:

        print(tmp)

        exit()

    else:

        ans = tmp


H = int(eval(input()))





def attackCount(hitpoint):

    if hitpoint == 1:

        return 1

    elif hitpoint > 1:

        return 2*attackCount(hitpoint//2)+1

    else:

        raise ValueError





print((attackCount(H)))
H = int(eval(input()))
ans = 1
if H == 1:
    print((1))
    exit()
while True:
    tmp = ans * 2 + 1
    if H > ans and H <= tmp:
        print(tmp)
        exit()
    else:
        ans = tmp

H = int(eval(input()))


def attackCount(hitpoint):
    if hitpoint == 1:
        return 1
    elif hitpoint > 1:
        return 2 * attackCount(hitpoint // 2) + 1
    else:
        raise ValueError


print((attackCount(H)))

-ans = 1 -if H == 1: -    print((1)) -    exit() -while True: -    tmp = ans * 2 + 1 -    if H > ans and H <= tmp: -        print(tmp) -        exit() + + +def attackCount(hitpoint): +    if hitpoint == 1: +        return 1 +    elif hitpoint > 1: +        return 2 * attackCount(hitpoint // 2) + 1 -        ans = tmp +        raise ValueError + + +print((attackCount(H)))