H=int(eval(input()))



def rec(a):

    if a==1:

        return 1

    else:

        return rec(a//2)*2+1

    

print((rec(H)))
import sys

input = sys.stdin.readline



def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    H=I()

    ans=0

    

    def f(x):

        if x==0:

            return 0

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

    

    print((f(H)))

        



main()

H = int(eval(input()))


def rec(a):
    if a == 1:
        return 1
    else:
        return rec(a // 2) * 2 + 1


print((rec(H)))

import sys

input = sys.stdin.readline


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    H = I()
    ans = 0

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

    print((f(H)))


main()

-H = int(eval(input())) +import sys + +input = sys.stdin.readline -def rec(a): -    if a == 1: -        return 1 -    else: -        return rec(a // 2) * 2 + 1 +def I(): +    return int(eval(input())) -print((rec(H))) +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    H = I() +    ans = 0 + +    def f(x): +        if x == 0: +            return 0 +        return f(x // 2) * 2 + 1 + +    print((f(H))) + + +main()