#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
long i;
for(i=0;s[i]!=’\0’;i++){
if(s[0]=='9')
continue;
else{
int temp = s[i] - '0';
if(temp >=5)
temp = 9 - temp;
s[i] = temp + '0';
}
}
cout<<s<<endl;
return 0;
}