import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} Main public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  } main {
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  } try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    } catch (Exception e) {
      System.out.println("out");
    } Exception e {
      System.out.println("out");
    } System.out.println("out") System.out.println System.out System System.out "out" {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n; n n=Integer.parseInt(sc.next()) n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==111 n 111 {
        System.out.println(999);
      } System.out.println(999) System.out.println System.out System System.out 999 if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==119 n 119 {
        System.out.println(991);
      } System.out.println(991) System.out.println System.out System System.out 991 if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==191 n 191 {
        System.out.println(919);
      } System.out.println(919) System.out.println System.out System System.out 919 if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==199 n 199 {
        System.out.println(911);
      } System.out.println(911) System.out.println System.out System System.out 911 if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==911 n 911 {
        System.out.println(199);
      } System.out.println(199) System.out.println System.out System System.out 199 if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==919 n 919 {
        System.out.println(191);
      } System.out.println(191) System.out.println System.out System System.out 191 if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      } n==991 n 991 {
        System.out.println(119);
      } System.out.println(119) System.out.println System.out System System.out 119 if(n==999){
        System.out.println(111);
      } n==999 n 999 {
        System.out.println(111);
      } System.out.println(111) System.out.println System.out System System.out 111 String[] args args public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
} Main
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int n;
      n=Integer.parseInt(sc.next());

      if(n==111){
        System.out.println(999);
      }else if(n==119){
        System.out.println(991);
      }else if(n==191){
        System.out.println(919);
      }else if(n==199){
        System.out.println(911);
      }else if(n==911){
        System.out.println(199);
      }else if(n==919){
        System.out.println(191);
      }else if(n==991){
        System.out.println(119);
      }else if(n==999){
        System.out.println(111);
      }
      
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}
