import java.util.Scanner;
public class INVERT {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int n=input.nextInt();
n=invert(n);
reverse(n);
}
public static int invert(int n) {
int len=Integer.toString(n).length();
int temp,a=0,c=0;
while(a<len) {
temp=n%10;
n=n/10;
if(temp>=5) temp=9-temp;
c=c*10+temp;
a++;
}
return(c);
}
public static void reverse(int n) {
int len=Integer.toString(n).length();
int temp,a=0,c=0;
while(a<len) {
temp=n%10;
n=n/10;
c=c*10+temp;
a++;
}
System.out.println(c);
}
}
