

#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define inf 1e18
#define N 1000043
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
#define pll pair<ll,ll>
#define int ll
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string a;
    cin >> a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.length();i++){
        if(a[i]=='9')   a[i]='6';
        else if(a[i]=='6')   a[i]='9';
    }
    cout << a << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ull maxprim = 1e9 + 7;
ull gcd (ull a, ull b) {
    return b ? gcd (b, a % b) : a;
}
int main()
{    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    cout.tie(NULL);
    ll tst,n,i,j,ite=0,flg,m,lim,k,l,r,q,res,i1,j1,x;
    tst=1;//cin>>tst;
    while(tst--){
      string str;
      cin>>str;
      for(i = str.length() - 1;i>=0;i--){
        if(str[i]=='6')cout<<'9';
        else if(str[i]=='9')cout<<'6';
        else cout<<str[i];
      }
    }
    return 0;
}