import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(1 <= n && n <= 9) {
        	System.out.println(n);
        } else if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        }
        
        
        sc.close();
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(1 <= n && n <= 9) {
        	System.out.println(n);
        } else if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        }
        
        
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(1 <= n && n <= 9) {
        	System.out.println(n);
        } else if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        }
        
        
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(1 <= n && n <= 9) {
        	System.out.println(n);
        } else if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        }
        
        
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc if(1 <= n && n <= 9) {
        	System.out.println(n);
        } else if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        } 1 <= n && n <= 9 1 <= n 1 n n <= 9 n 9 {
        	System.out.println(n);
        } System.out.println(n) System.out.println System.out System System.out n if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        } 10 <= n && n <= 99 10 <= n 10 n n <= 99 n 99 {
        	System.out.println(9);
        } System.out.println(9) System.out.println System.out System System.out 9 if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        } 100 <= n && n <= 999 100 <= n 100 n n <= 999 n 999 {
        	System.out.println(9 + n - 99);
        } System.out.println(9 + n - 99) System.out.println System.out System System.out 9 + n - 99 9 + n 9 n 99 if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        } 1000 <= n && n <= 9999 1000 <= n 1000 n n <= 9999 n 9999 {
        	System.out.println(909);
        } System.out.println(909) System.out.println System.out System System.out 909 if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        } 10000 <= n && n <= 99999 10000 <= n 10000 n n <= 99999 n 99999 {
        	System.out.println(909 + n - 9999);
        } System.out.println(909 + n - 9999) System.out.println System.out System System.out 909 + n - 9999 909 + n 909 n 9999 {
        	System.out.println(90909);
        } System.out.println(90909) System.out.println System.out System System.out 90909 sc.close() sc.close sc String[] args args
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        if(1 <= n && n <= 9) {
        	System.out.println(n);
        } else if(10 <= n && n <= 99) {
        	System.out.println(9);
        } else if(100 <= n && n <= 999) {
        	System.out.println(9 + n - 99);
        } else if(1000 <= n && n <= 9999) {
        	System.out.println(909);
        } else if(10000 <= n && n <= 99999) {
        	System.out.println(909 + n - 9999);
        } else {
        	System.out.println(90909);
        }
        
        
        sc.close();
    }
}
