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