import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } 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 ans = 0; ans 0 if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        } N < 10 N 10 {
            System.out.println(N);
        } System.out.println(N) System.out.println System.out System System.out N if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        } N < 100 N 100 {
            System.out.println(9);
        } System.out.println(9) System.out.println System.out System System.out 9 if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        } N < 1000 N 1000 {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } ans += 9 ans 9 String stringN = String.valueOf(N); stringN String.valueOf(N) String.valueOf String N String lead = stringN.substring(0, 1); lead stringN.substring(0, 1) stringN.substring stringN 0 1 String rest = stringN.substring(1, stringN.length()); rest stringN.substring(1, stringN.length()) stringN.substring stringN 1 stringN.length() stringN.length stringN ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100 ans Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100 Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100 Integer.parseInt(rest) Integer.parseInt Integer rest 1 (Integer.parseInt(lead) - 1) * 100 (Integer.parseInt(lead) - 1) Integer.parseInt(lead) Integer.parseInt Integer lead 1 100 System.out.println(ans) System.out.println System.out System System.out ans if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        } N < 10000 N 10000 {
            System.out.println(909);
        } System.out.println(909) System.out.println System.out System System.out 909 if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        } N < 100000 N 100000 {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } ans += 909 ans 909 String stringN = String.valueOf(N); stringN String.valueOf(N) String.valueOf String N String lead = stringN.substring(0, 1); lead stringN.substring(0, 1) stringN.substring stringN 0 1 String rest = stringN.substring(1, stringN.length()); rest stringN.substring(1, stringN.length()) stringN.substring stringN 1 stringN.length() stringN.length stringN ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000 ans Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000 Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000 Integer.parseInt(rest) Integer.parseInt Integer rest 1 (Integer.parseInt(lead) - 1) * 10000 (Integer.parseInt(lead) - 1) Integer.parseInt(lead) Integer.parseInt Integer lead 1 10000 System.out.println(ans) System.out.println System.out System System.out ans {
            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) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    }
}
