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

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    h <- getInt
    print $ solve h

solve :: Int -> Int
solve 1 = 1
solve x = 1 + 2 * (solve $ x `div` 2)