https://codeforces.com/problemset/problem/514/A
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
string s; cin>>s;
for(int i=0;i<s.size();i++)
{
int a=s[i]-'0',b=9-a;
if(min(a,b)==0&&!i) continue;
s[i]='0'+min(a,b);
}
cout<<s;
return 0;
}