import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      String str = String.valueOf(n);
      String x1 = str.substring(0,1);
      String x2 = str.substring(1,2);
      String x3 = str.substring(2,3);
      if(x1.equals("1"))x1 = "9";
      else x1 = "1";
      if(x2.equals("1"))x2 = "9";
      else x2 = "1";
      if(x3.equals("1"))x3 = "9";
      else x3 = "1";
      String str1 = x1+x2+x3;
      int n1 = Integer.parseInt(str1);
      System.out.println(n1);
      sc.close();
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz