import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()

    if (n < 10) {
        println(n)
    } else if (n < 100) {
        println(9)
    } else if (n < 1000) {
        println(n - 90) // - 10..99
    } else if (n < 10000) {
        println(9+900)
    } else if (n < 100000) { // 10000..99999
        println(n - 10000 + 1 + 900 + 9)
    } else { // 100000...
        println(90000 + 900 + 9)
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun println(value : Any) {
    pw.println(value)
}