#include <bits/stdc++.h>

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define fi first
#define se second
#define pb push_back
#define fr(i, l, r) for (int i = (l); i <= (r); i++)

using namespace std;
typedef long long ll;

void solve() {
 string s;
 cin>>s;
 string a="";
 for(int i=s.size()-1;i>=0;i--){
    if(s[i]=='2')a+="5";
    else if(s[i]=='5')a+="2";
    else a+=s[i];
 }
 bool f=0;
 for(int i=0;i<a.size();i+=1){
    if(f and a[i]=='0')cout<<a[i];
    else if(a[i]!='0')f=1,cout<<a[i];
 }
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}
