import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	} main {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int answer = 0; answer 0 if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		} N == 100000 N 100000 {
			answer = 9 + 900 + 90000;
		} answer = 9 + 900 + 90000 answer 9 + 900 + 90000 9 + 900 + 90000 9 900 90000 if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		} N <= 99999 && N >= 10000 N <= 99999 N 99999 N >= 10000 N 10000 {
			answer = 9 + 900 + (N - 9999);
		} answer = 9 + 900 + (N - 9999) answer 9 + 900 + (N - 9999) 9 + 900 + (N - 9999) 9 900 (N - 9999) N 9999 if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		} N <= 9999 && N >= 1000 N <= 9999 N 9999 N >= 1000 N 1000 {
			answer = 9 + 900;
		} answer = 9 + 900 answer 9 + 900 9 900 if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		} N <= 999 && N >= 100 N <= 999 N 999 N >= 100 N 100 {
			answer = 9 + (N - 99);
		} answer = 9 + (N - 99) answer 9 + (N - 99) 9 (N - 99) N 99 if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		} N <= 99 && N >= 10 N <= 99 N 99 N >= 10 N 10 {
			answer = 9;
		} answer = 9 answer 9 {
			answer = N;
		} answer = N answer N System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	}
} Main
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int answer = 0;
		
		if (N == 100000) {
			answer = 9 + 900 + 90000;
		} else if (N <= 99999 && N >= 10000) {
			answer = 9 + 900 + (N - 9999);
		} else if (N <= 9999 && N >= 1000) {
			answer = 9 + 900;
		} else if (N <= 999 && N >= 100) {
			answer = 9 + (N - 99);
		} else if (N <= 99 && N >= 10) {
			answer = 9;
		} else {
			answer = N;
		}

		System.out.println(answer);
	}
}