import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
  	/**
    *
    *
    */
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		int inputNum = Integer.parseInt(line);
		int Num_1 = Num_reverse(inputNum - (inputNum/10)*10);
		int Num_10 = Num_reverse(inputNum/10 - (inputNum/100)*10);
		int Num_100 = Num_reverse(inputNum/100);
		
		System.out.println(Num_1 + 10*Num_10 + 100*Num_100);
	}
	public static int Num_reverse(int num) {
		if(num == 1) {
			num = 9;
		} else if (num == 9) {
			num = 1;
		}
		return num;
	}
}
/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