#include <bits/stdc++.h>
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long
using namespace std;
const int NN=1e3+60,N=1e6+70,MOD=1e9+7,inf=1e18+7,pr=420;
int n,m;
char a[NN][NN];//[NN];
//vector<int> g[N];
int binpow(int n,int m){
    if (!m) return 1;
    if (!m%2){ int a=binpow(n,m/2); return a*a;}
    else return n*binpow(n,m-1);
}
void junk(){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    s=to_string(stoi(s));
    for(int i=0;i<s.size();i++){
        if (s[i]=='5'){
            s[i]='2';
        }else if (s[i]=='2'){
            s[i]='5';
        }
    }
    cout<<s;
    
}
signed main(/*ITS OVER ANAKIN. I HAVE A HIGH GROUND*/){//file("");
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int Test=1;//cin>>Test;
while(Test--) junk();
/*YOU UNDERESTIMATE MY POWER*/
}