import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    }

} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    }

} Main public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    } main {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int n = Integer.parseInt(in.nextLine()); n Integer.parseInt(in.nextLine()) Integer.parseInt Integer in.nextLine() in.nextLine in int count = 0; count 0 if( n < 10 ) {
            System.out.println(n);
            return;
        } n < 10 n 10 {
            System.out.println(n);
            return;
        } System.out.println(n) System.out.println System.out System System.out n return; if( n < 100 ){
            System.out.println( 9 );
            return;
        } n < 100 n 100 {
            System.out.println( 9 );
            return;
        } System.out.println( 9 ) System.out.println System.out System System.out 9 return; if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        } n < 1000 n 1000 {
            System.out.println( n - 99 + 9 );
            return;
        } System.out.println( n - 99 + 9 ) System.out.println System.out System System.out n - 99 + 9 n - 99 n 99 9 return; if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        } n < 10000 n 10000 {
            System.out.println( 999 - 99 + 9);
            return;
        } System.out.println( 999 - 99 + 9) System.out.println System.out System System.out 999 - 99 + 9 999 - 99 999 99 9 return; if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        } n < 100000 n 100000 {
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        } System.out.println( n - 9999 + 999 - 99 + 9) System.out.println System.out System System.out n - 9999 + 999 - 99 + 9 n - 9999 + 999 - 99 n - 9999 + 999 n - 9999 n 9999 999 99 9 return; System.out.println( 90909 ) System.out.println System.out System System.out 90909 String[] args args public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    }

} public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());

        int count = 0;
        if( n < 10 ) {
            System.out.println(n);
            return;
        }
        if( n < 100 ){
            System.out.println( 9 );
            return;
        }
        if( n < 1000 ){
            System.out.println( n - 99 + 9 );
            return;
        }
        if( n < 10000 ){
            System.out.println( 999 - 99 + 9);
            return;
        }
        if( n < 100000 ){
            System.out.println( n - 9999 + 999 - 99 + 9);
            return;
        }
        System.out.println( 90909 );

    }

}
