import numpy as np

H=eval(input())

H=int(H)



def count(H):

	count=1

	while True:

		if int(H/2)==0:

			break

		else:

			H=int(H/2)

			count+=1

			continue

	return count



A=0

for i in range(int(count(H))):

	A+=2**i

			

print(A)
# coding: utf-8

# Your code here!



H=int(eval(input()))

count=0

ans=0

while H>1:

    H=H//2

    count+=1

for i in range(count+1):

    ans+=2**i

print(ans)
import numpy as np

H = eval(input())
H = int(H)


def count(H):
    count = 1
    while True:
        if int(H / 2) == 0:
            break
        else:
            H = int(H / 2)
            count += 1
            continue
    return count


A = 0
for i in range(int(count(H))):
    A += 2**i
print(A)

# coding: utf-8
# Your code here!
H = int(eval(input()))
count = 0
ans = 0
while H > 1:
    H = H // 2
    count += 1
for i in range(count + 1):
    ans += 2**i
print(ans)

-import numpy as np - -H = eval(input()) -H = int(H) - - -def count(H): -    count = 1 -    while True: -        if int(H / 2) == 0: -            break -        else: -            H = int(H / 2) -            count += 1 -            continue -    return count - - -A = 0 -for i in range(int(count(H))): -    A += 2**i -print(A) +# coding: utf-8 +# Your code here! +H = int(eval(input())) +count = 0 +ans = 0 +while H > 1: +    H = H // 2 +    count += 1 +for i in range(count + 1): +    ans += 2**i +print(ans)