import sys

from functools import lru_cache

sys.setrecursionlimit(1000000)





@lru_cache(maxsize=None)

def a(n):

    if n == 1:

        return 1

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





print((a(int(eval(input())))))

from math import log



h=int(eval(input()))

a=int(log(h,2))

print((pow(2,a+1)-1))

import sys
from functools import lru_cache

sys.setrecursionlimit(1000000)


@lru_cache(maxsize=None)
def a(n):
    if n == 1:
        return 1
    return 1 + 2 * a(n // 2)


print((a(int(eval(input())))))

from math import log

h = int(eval(input()))
a = int(log(h, 2))
print((pow(2, a + 1) - 1))

-import sys -from functools import lru_cache +from math import log -sys.setrecursionlimit(1000000) - - -@lru_cache(maxsize=None) -def a(n): -    if n == 1: -        return 1 -    return 1 + 2 * a(n // 2) - - -print((a(int(eval(input()))))) +h = int(eval(input())) +a = int(log(h, 2)) +print((pow(2, a + 1) - 1))