import java.lang.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        }
        sc.close();
    }
} import java.lang.*; lang.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        }
        sc.close();
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        }
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }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 int kari = n+1; kari n+1 n 1 int keta = 1; keta 1 while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        } (int)(kari/10)!=0 (int)(kari/10) kari 10 0 {
            keta++;
            kari = (int)(kari/10);
        } keta++ keta kari = (int)(kari/10) kari (int)(kari/10) kari 10 if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        } keta == 1 keta 1 {
            System.out.println(n);
        } System.out.println(n) System.out.println System.out System System.out n if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        } keta == 2 keta 2 {
            System.out.println(9);
        } System.out.println(9) System.out.println System.out System System.out 9 if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        } keta == 3 keta 3 {
            System.out.println((10+n-100));
        } System.out.println((10+n-100)) System.out.println System.out System System.out (10+n-100) 10+n 10 n 100 if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        } keta == 4 keta 4 {
            System.out.println(909);
        } System.out.println(909) System.out.println System.out System System.out 909 if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        } keta == 5 keta 5 {
            System.out.println((910+n-10000));
        } System.out.println((910+n-10000)) System.out.println System.out System System.out (910+n-10000) 910+n 910 n 10000 {
            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 public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        }
        sc.close();
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        }
        sc.close();
    }
} Main
import java.lang.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kari = n+1;
        int keta = 1;
        while((int)(kari/10)!=0){
            keta++;
            kari = (int)(kari/10);
        }
        if(keta == 1){
            System.out.println(n);
        }else if(keta == 2){
            System.out.println(9);
        }else if(keta == 3){
            System.out.println((10+n-100));
        }else if(keta == 4){
            System.out.println(909);
        }else if(keta == 5){
            System.out.println((910+n-10000));
        }else{
            System.out.println(90909);
        }
        sc.close();
    }
}