
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn :: IO Int
    let nLen = length (show n)
    let rest = if odd nLen then (if nLen==1 then n else 1 + n - (10 ^ (nLen-1))) else 0
    print (solve (nLen-1) + rest)



solve n
    | n <= 0    = 0
    | n == 1    = 9
    | even n    = solve (n-1)
    | otherwise = (9*(10 ^ (n-1))) + solve (n-2)

