import bisect

H=int(input())
A=[2**x for x in range(51)]

if H==1:
  print(1)
elif H==2:
  print(3)
else:
  index=bisect.bisect_right(A,H) 
  print(sum(A[:index]))
3298e1bf70ea094a007974eddda4c985bcd004ef
<mask token>

<mask token>
if H == 1:
    print(1)
elif H == 2:
    print(3)
else:
    index = bisect.bisect_right(A, H)
    print(sum(A[:index]))

<mask token>
H = int(input())
A = [(2 ** x) for x in range(51)]
if H == 1:
    print(1)
elif H == 2:
    print(3)
else:
    index = bisect.bisect_right(A, H)
    print(sum(A[:index]))

import bisect
H = int(input())
A = [(2 ** x) for x in range(51)]
if H == 1:
    print(1)
elif H == 2:
    print(3)
else:
    index = bisect.bisect_right(A, H)
    print(sum(A[:index]))

import bisect

H=int(input())
A=[2**x for x in range(51)]

if H==1:
  print(1)
elif H==2:
  print(3)
else:
  index=bisect.bisect_right(A,H) 
  print(sum(A[:index]))