import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  }
} Main public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  } main {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int N6 = N / 100000 % 10; N6 N / 100000 % 10 N / 100000 N 100000 10 int N5 = N / 10000 % 10; N5 N / 10000 % 10 N / 10000 N 10000 10 int N4 = N / 1000 % 10; N4 N / 1000 % 10 N / 1000 N 1000 10 int N3 = N / 100 % 10; N3 N / 100 % 10 N / 100 N 100 10 int N2 = N / 10 % 10; N2 N / 10 % 10 N / 10 N 10 10 int result = 0; result 0 if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    } N6 == 1 N6 1 {
      result = 90909;
    } result = 90909 result 90909 if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    } N5 != 0 N5 0 {
      result = (N - 9999) + 909;
    } result = (N - 9999) + 909 result (N - 9999) + 909 (N - 9999) N 9999 909 if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    } N4 != 0 N4 0 {
      result = 909;
    } result = 909 result 909 if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    } N3 != 0 N3 0 {
      result = (N - 99) + 9;
    } result = (N - 99) + 9 result (N - 99) + 9 (N - 99) N 99 9 if(N2 != 0){
      result = 9;
    } else {
      result = N;
    } N2 != 0 N2 0 {
      result = 9;
    } result = 9 result 9 {
      result = N;
    } result = N result N System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  }
} public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    
    int N6 = N / 100000 % 10;
    int N5 = N / 10000 % 10;
    int N4 = N / 1000 % 10;
    int N3 = N / 100 % 10;
    int N2 = N / 10 % 10;
    
    int result = 0;
    if(N6 == 1){
      result = 90909;
    } else if(N5 != 0){
      result = (N - 9999) + 909;
    } else if(N4 != 0){
      result = 909;
    } else if(N3 != 0){
      result = (N - 99) + 9;
    } else if(N2 != 0){
      result = 9;
    } else {
      result = N;
    }
    
    System.out.println(result);
  }
}
