let n = stdin.ReadLine() |> int

let rec getLength a =
    if a <= 0 then 0
    else 1 + getLength (a / 10)

let rec getAns n = 
    match getLength n with
    |0 -> 0
    |1 -> n 
    |m when m % 2 = 0 -> getAns ((pown 10 (m - 1)) - 1)
    |m when m % 2 = 1 -> n - pown 10 (m - 1) + 1 + getAns(n / 10)

getAns n |> stdout.WriteLine