import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	} main {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long N = sc.nextLong(); N sc.nextLong() sc.nextLong sc if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} N <= 9 N 9 {
			System.out.println(N);
		} System.out.println(N) System.out.println System.out System System.out N if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} N <= 99 N 99 {
			System.out.println(9);
		} System.out.println(9) System.out.println System.out System System.out 9 if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} N <= 999 N 999 {
			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 - 99) N 99 if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} N <= 9999 N 9999 {
			System.out.println(9 + (999 - 99));
		} System.out.println(9 + (999 - 99)) System.out.println System.out System System.out 9 + (999 - 99) 9 (999 - 99) 999 99 if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} N <= 99999 N 99999 {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} System.out.println(9 + (999 - 99) + (N - 9999)) System.out.println System.out System System.out 9 + (999 - 99) + (N - 9999) 9 + (999 - 99) + (N - 9999) 9 (999 - 99) 999 99 (N - 9999) N 9999 if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} N <= 999999 N 999999 {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		} System.out.println(9 + (999 - 99) + (99999 - 9999)) System.out.println System.out System System.out 9 + (999 - 99) + (99999 - 9999) 9 + (999 - 99) + (99999 - 9999) 9 (999 - 99) 999 99 (99999 - 9999) 99999 9999 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		if (N <= 9) {
			System.out.println(N);
		} else if (N <= 99) {
			System.out.println(9);
		} else if (N <= 999) {
			System.out.println(9 + (N - 99));
		} else if (N <= 9999) {
			System.out.println(9 + (999 - 99));
		} else if (N <= 99999) {
			System.out.println(9 + (999 - 99) + (N - 9999));
		} else if (N <= 999999) {
			System.out.println(9 + (999 - 99) + (99999 - 9999));
		}
	}
}
