#include <bits/stdc++.h>  
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
#define fi(i,a,b) for(ll i = (a); i < (b); i++)
#define fr(i,a,b) for(ll i = (a); i >=(b); i--)
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define mp make_pair
#define pb push_back
#define inf 2e15
#define inp(arr,z) for(int i=0; i<z; i++)cin>>arr[i]
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
void solve();
int main(){
fast_cin();
chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
////freopen("output.txt", "w", stdout);
#endif
ll t=1;
// cin >> t;
while (t--)
{solve();cout<<endl;}
chrono::high_resolution_clock::time_point t2 = chrono::high_resolution_clock::now();
chrono::duration<double, std::milli> time_span = t2 - t1;
//cout<<time_span.count();
return 0;
}
ll power(ll a , ll b ){ll r=1;ll o=a;if(b<=0)return 1;
     while(b!=0){if(b%2)r*=o,b--; else {b/=2; o=o*o;}}
   return r;}









void solve(){


string s; cin>>s;
reverse(all(s));
fi(i,0,s.size()){if(s[i]=='9')s[i]='6';else if(s[i]=='6')s[i]='9';}
cout<<s;
}
#include <bits/stdc++.h> 
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++){
	    
	    if(i<(n/2)){
	        char temp =s[i];
	        s[i]=s[n-1-i];
	        s[n-1-i]=temp;
	    }
	    
	    if(s[i]=='6'){
	        s[i]='9';
	    }
	    else if(s[i]=='9'){
	        s[i]='6';
	    }
	    
	    cout<<s[i];
	}
	return 0;
}