#include<bits/stdc++.h>
#define ld long double
#define ss second
#define ff first
#define int long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define ll long long
#define rall(x) x.rbegin(), x.rend()
#define sz(a) (int)a.size()
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define sp(x) fixed << setprecision(x)
#define ms multiset
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y);
#define mll map<ll,ll> 
using namespace std;
const string YES = "YES";
const string NO = "NO";
const long long MOD = 1e9 + 7;
const int N = 1e5 + 5;
const long long inf = 9e18;
const int M = 3e3 + 5;
const double EPS = 1e-6;
const ll neg = -1;
const string imp = "impossible";

  
void setIO(string name = "") {
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin); 
        freopen((name + ".out").c_str(), "w", stdout);
    }
}
void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}



void solve(){
  string k;
    cin >> k;

    // reverse the string
    reverse(k.begin(), k.end());

    // replace 2 with 5 and vice versa
    for (char &c : k) {
        if (c == '2') c = '5';
        else if (c == '5') c = '2';
    }
   k.erase(0, min(k.find_first_not_of('0'), k.size()-1));

    cout << k << endl;

  


}
signed main(){
  boost();
  ll test = 1;
  //cin >> test; 
  while(test--) solve(); 
}