import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Int

getInts :: IO [Int]
getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

f 0 = 1
f 1 = 1
f n = 1 + f (n `div` 2)

main :: IO ()
main = do
  h <- readLn :: IO Int64
  
  print $ 2 ^ (f h) - 1