import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

import qualified Data.List as L

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  h <- getInt
  solve h

solve :: Int -> IO ()
solve h = do
  let n = 1
      a = solve' n h
      r = sum [2^(i-1) | i <- [1 .. a]]
  print r

solve' :: Int -> Int -> Int
solve' n h = do
  let x = h `div` 2
    in if h > 1 then solve' (n+1) x else n