import java.util.Scanner;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	}
} import java.util.Scanner; Scanner java.util public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	}
} Main public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	} main {
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int num = scan.nextInt(); num scan.nextInt() scan.nextInt scan if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		} num < 10 num 10 {
			System.out.println(num);
		} System.out.println(num) System.out.println System.out System System.out num if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		} num >= 10 && num <= 99 num >= 10 num 10 num <= 99 num 99 {
			System.out.println(9);
		} System.out.println(9) System.out.println System.out System System.out 9 if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		} num >= 100 && num <= 999 num >= 100 num 100 num <= 999 num 999 {
			System.out.println(9 + (num - 99));
		} System.out.println(9 + (num - 99)) System.out.println System.out System System.out 9 + (num - 99) 9 (num - 99) num 99 if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		} num >= 1000 && num <= 9999 num >= 1000 num 1000 num <= 9999 num 9999 {
			System.out.println(909);
		} System.out.println(909) System.out.println System.out System System.out 909 if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		} num >= 10000 && num <= 99999 num >= 10000 num 10000 num <= 99999 num 99999 {
			System.out.println(909 + (num - 9999));
		} System.out.println(909 + (num - 9999)) System.out.println System.out System System.out 909 + (num - 9999) 909 (num - 9999) num 9999 if(num == 100000){
			System.out.println(90909);
		} num == 100000 num 100000 {
			System.out.println(90909);
		} 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 scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	}
} public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	}
} Main
import java.util.Scanner;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int num = scan.nextInt();
		
		if(num < 10){
			System.out.println(num);
		} else if(num >= 10 && num <= 99){
			System.out.println(9);
		} else if(num >= 100 && num <= 999){
			System.out.println(9 + (num - 99));
		} else if(num >= 1000 && num <= 9999){
			System.out.println(909);
		} else if(num >= 10000 && num <= 99999){
			System.out.println(909 + (num - 9999));
		} else if(num == 100000){
			System.out.println(90909);
		}
		
	}
}