main = do 
    n <- (read :: String -> Int) <$> getLine
    print $ test n
    where 
        test m
            | m < 10 = m
            | m < 100 = 9
            | m < 1000 = m-99+9
            | m < 10000 = 999-99+9
            | m < 100000 = m-9999+999-99+9
            | otherwise = 99999-9999+999-99+9