import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 100000) {
			System.out.println(90909);
		}else if(n < 100000 & n >= 10000){
			System.out.println(909 + n - 9999);
		}else if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 100000) {
			System.out.println(90909);
		}else if(n < 100000 & n >= 10000){
			System.out.println(909 + n - 9999);
		}else if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 100000) {
			System.out.println(90909);
		}else if(n < 100000 & n >= 10000){
			System.out.println(909 + n - 9999);
		}else if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc if(n == 100000) {
			System.out.println(90909);
		}else if(n < 100000 & n >= 10000){
			System.out.println(909 + n - 9999);
		}else if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		} n == 100000 n 100000 {
			System.out.println(90909);
		} System.out.println(90909) System.out.println System.out System System.out 90909 if(n < 100000 & n >= 10000){
			System.out.println(909 + n - 9999);
		}else if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		} n < 100000 & n >= 10000 n < 100000 n 100000 n >= 10000 n 10000 {
			System.out.println(909 + n - 9999);
		} System.out.println(909 + n - 9999) System.out.println System.out System System.out 909 + n - 9999 909 + n 909 n 9999 if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		} n < 10000 & n >= 1000 n < 10000 n 10000 n >= 1000 n 1000 {
			System.out.println(909);
		} System.out.println(909) System.out.println System.out System System.out 909 if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		} n < 1000 & n >= 100 n < 1000 n 1000 n >= 100 n 100 {
			System.out.println(9 + n -99);
		} System.out.println(9 + n -99) System.out.println System.out System System.out 9 + n -99 9 + n 9 n 99 if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		} n < 100 & n >= 10 n < 100 n 100 n >= 10 n 10 {
			System.out.println(9);
		} System.out.println(9) System.out.println System.out System System.out 9 {
			System.out.println(n);
		} System.out.println(n) System.out.println System.out System System.out n String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 100000) {
			System.out.println(90909);
		}else if(n < 100000 & n >= 10000){
			System.out.println(909 + n - 9999);
		}else if(n < 10000 & n >= 1000) {
			System.out.println(909);
		}else if(n < 1000 & n >= 100){
			System.out.println(9 + n -99);
		}else if(n < 100 & n >= 10){
			System.out.println(9);
		}else {
			System.out.println(n);
		}
	}
} public class Main {

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

public class Main {

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