import java.util.Scanner;

public class Main{
	public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	}

	public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	}

	public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	}
} Main public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	} main {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int printNum = 0; printNum 0 int ketasuu = cheackKetasuu(N); ketasuu cheackKetasuu(N) cheackKetasuu N if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		} ketasuu == 1 ketasuu 1 {
			printNum = N;
		} printNum = N printNum N if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		} ketasuu == 2 ketasuu 2 {
			printNum = 9;
		} printNum = 9 printNum 9 if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		} ketasuu == 3 ketasuu 3 {
			printNum = 9 + N -99;
		} printNum = 9 + N -99 printNum 9 + N -99 9 + N 9 N 99 if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		} ketasuu == 4 ketasuu 4 {
			printNum = 9 + 900;
		} printNum = 9 + 900 printNum 9 + 900 9 900 if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		} ketasuu == 5 ketasuu 5 {
			printNum = 9 + 900 + N - 9999;
		} printNum = 9 + 900 + N - 9999 printNum 9 + 900 + N - 9999 9 + 900 + N 9 + 900 + N 9 900 N 9999 if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		} ketasuu == 6 ketasuu 6 {
			printNum = 9 + 900 + 90000;
		} printNum = 9 + 900 + 90000 printNum 9 + 900 + 90000 9 + 900 + 90000 9 900 90000 System.out.println(printNum) System.out.println System.out System System.out printNum String arge[] arge public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	} cheackKetasuu {
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	} int ketasuu = 0; ketasuu 0 int count = 6; count 6 for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		} int i = 100000; int i = 100000; i 100000 1 <= i 1 i i /=10 i /=10 i 10 {
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		} {
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		} if(1 <= N / i){
				ketasuu = count;
				break;
			} 1 <= N / i 1 N / i N i {
				ketasuu = count;
				break;
			} ketasuu = count ketasuu count break; count -- count return ketasuu; ketasuu int N N public class Main{
	public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	}

	public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	}
} public class Main{
	public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	}

	public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String arge[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		// 1 <= N <= 100000
		int printNum = 0;
		int ketasuu = cheackKetasuu(N);
		if(ketasuu == 1 ){
			printNum = N;
		}else if(ketasuu == 2){
			printNum = 9;
		}else if(ketasuu == 3){
			printNum = 9 + N -99;
		}else if(ketasuu == 4){
			printNum = 9 + 900;
		}else if(ketasuu == 5){
			printNum = 9 + 900 + N - 9999;
		}else if(ketasuu == 6){
			printNum = 9 + 900 + 90000;
		}
		// System.out.println(ketasuu);
		System.out.println(printNum);

	}

	public static int cheackKetasuu(int N){
		int ketasuu = 0;
		int count = 6;
		for(int i = 100000;1 <= i;i /=10){
			if(1 <= N / i){
				ketasuu = count;
				break;
			}
			count --;
		}
		return ketasuu;
	}
}