#include<iostream>
#include<vector>

using namespace std;

int main(){
  string S;
  string T="";
  cin >> S;
  
  for(int i=S.size()-1; i>=0; i--){
    T += S[i];
  }
  
  for(int i=0;i<T.size();i++){
    if(T[i]=='6'){
      T[i] = '9';
    }else if(T[i] == '9'){
      T[i] = '6';
    }      
  }
  
  cout << T << endl;
}
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define vll vector<ll> 
#define vvl vector<vll>
#define pii pair<ll,ll>
#define F first
#define S second
#define M 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll min(ll a,ll b){if(a<b) return a; return b;}
ll mod=998244353;
 
ll po(ll x, ll y){
    if(y==0)
    return 1;
    if(y%2){
        return ((x)*(po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
    }
   return ((po(x,y/2)%M)*(po(x,y/2)%M) + M)%M;
}
 
void seive(bool prime[]){
    //bool prime[100002]; 
     
  
    for (ll p=2; p*p<=1000001; p++) 
    { 
        if (prime[p]) 
        { 
            for (ll i=p*p; i<=1000001; i+=p) 
                prime[i] = false; 
        } 
    }
}
    
ll powermod(ll x,ll y,ll p)  {
  ll res = 1;     
    x = x % p; 
 if (x == 0) return 0;  
    while (y > 0)  
    {     if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
 
ll gcd(ll x, ll y){
    if (y == 0)
    return x;
    else
    return gcd(y, x % y);
}
 
ll nck(ll n, ll k){
    ll C[k + 1];
    memset(C, 0, sizeof(C));
    C[0] = 1;
    for (ll i = 1; i <= n; i++) {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j]%M + C[j - 1]%M)%M;
    }
    return C[k]%M;
}
 
/*void call(vll &primefactor,int N){
    for(int i=1;i<N;i++)
    {
        primefactor[i]=i;
    }
    for(int i=2;i<N;i++)
    {
        if(primefactor[i]!=i)  
            continue;
        for(int j=i;j<N;j+=i)
            primefactor[j]=i;  
    }
}*/
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
    //cin>>t;
    while(t--){
        string s; cin>>s;
        ll n=s.size();
        fo(i,n)
        if(s[i]=='9')
        s[i]='6';
        else if(s[i]=='6')
        s[i]='9';
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
    return 0;
}