import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	} main {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int v = String.valueOf( n ).length(); v String.valueOf( n ).length() String.valueOf( n ).length String.valueOf( n ) String.valueOf String n if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		} v==1 v 1 {
			System.out.println(n%10);
		} System.out.println(n%10) System.out.println System.out System System.out n%10 n 10 if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		} v==2 v 2 {
			System.out.println("9");
		} System.out.println("9") System.out.println System.out System System.out "9" if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		} v==3 v 3 {
			System.out.println(9+(n/100-1)*100+n%100+1);
		} System.out.println(9+(n/100-1)*100+n%100+1) System.out.println System.out System System.out 9+(n/100-1)*100+n%100+1 n%100 9+(n/100-1)*100+n%100+1 9 (n/100-1)*100 (n/100-1) n/100 n 100 1 100 n%100 n 100 1 if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		} v==4 v 4 {
			System.out.println("909");
		} System.out.println("909") System.out.println System.out System System.out "909" if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		} v==5 v 5 {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		} System.out.println(909+(n/10000-1)*10000+n%10000+1) System.out.println System.out System System.out 909+(n/10000-1)*10000+n%10000+1 n%10000 909+(n/10000-1)*10000+n%10000+1 909 (n/10000-1)*10000 (n/10000-1) n/10000 n 10000 1 10000 n%10000 n 10000 1 {
			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 sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	}

} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	}

} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list_gold=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int n = sc.nextInt();
		int v = String.valueOf( n ).length();
		if(v==1) {
			System.out.println(n%10);
		}
		else if(v==2) {
			System.out.println("9");
		}
		else if(v==3) {
			System.out.println(9+(n/100-1)*100+n%100+1);
		}
		else if(v==4) {
			System.out.println("909");
		}
		else if(v==5) {
			System.out.println(909+(n/10000-1)*10000+n%10000+1);
		}
		else {
			System.out.println("90909");
		}
	}

}