toInt :: String -> Int
toInt = read :: String -> Int

countAttacks :: Int -> Int
countAttacks n
  | n == 1 = 1
  | otherwise = 1 + 2 * countAttacks (div n 2)

main = do
  s <- getLine
  putStrLn $ show $ countAttacks (toInt s)
