{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int
solve !n =
  let d = length $ show n
      k = 10 ^ (d - 1)
  in  if even d
        then sum $ map (\n -> 10 ^ n - 10 ^ (n - 1)) [1, 3 .. d]
        else (+ (n - k + 1)) $ sum $ map (\n -> 10 ^ n - 10 ^ (n - 1))
                                         [1, 3 .. d - 1]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  print $ solve n
