import java.util.Scanner;
import java.lang.Math;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if(num >=1)
{
int digits = (int)(Math.log10(num)) + 1;
int [] a = new int[digits];
for(int i = 0 ;i< digits ;i++)
{
a[i] = num%10;
num = num/10;
}
int result = 0;
for(int i =digits-1;i>=0 ; i–)
{
if(a[i]<9-a[i])
{
result = result10 + a[i];
}
else
{
result = result10 + (9-a[i]);
}
} System.out.println(result);
}
else
{System.out.println(“Invalid Input”);}
}
}