#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,a,b) for (int i = (a); i < (b); ++i)
#define erep(i,a,b) for (int i = (a); i <= (b); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),rend()
#define yn(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define fore(i,a) for(auto &i:a)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}

int main() {
  string s;
  cin >>s;
  reverse(all(s));
  fore(a,s) {
    if(a=='6') cout << '9';
    else if(a=='9') cout << '6';
    else cout << a;
  }
  cout << endl;
  return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
int main() {
char s[100001];
cin>>s;
int n;
n=strlen(s);
for(int i=n-1;i>=0;i--){
if(s[i]=='6'){
cout<<'9';
}
else if(s[i]=='9'){
cout<<'6';
}
else{
cout<<s[i];
}
}
}