from functools import lru_cache

import sys

sys.setrecursionlimit(10000000)

@lru_cache(maxsize= 10 ** 7)

def solve(n):

  if n == 1:

    return 1

  else:

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

h = int(eval(input()))

print((solve(h)))

def solve(n):

  if n == 1:

    return 1

  else:

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

h = int(eval(input()))

print((solve(h)))
from functools import lru_cache
import sys

sys.setrecursionlimit(10000000)


@lru_cache(maxsize=10**7)
def solve(n):
    if n == 1:
        return 1
    else:
        return solve(n // 2) * 2 + 1


h = int(eval(input()))
print((solve(h)))

def solve(n):
    if n == 1:
        return 1
    else:
        return solve(n // 2) * 2 + 1


h = int(eval(input()))
print((solve(h)))

-from functools import lru_cache -import sys - -sys.setrecursionlimit(10000000) - - -@lru_cache(maxsize=10**7)