// BEST TEACHERS: NAZAROV SHARAF and USMONZODA SOMON
//                littbird           another_love
#include <bits/stdc++.h>
//#define ONLINE_JUDGE
#define fi first
#define se second
#define pb push_back
#define yes cout << "YES"
#define no cout << "NO"
#define int long long
#define in insert
#define endl '\n'
#define ld long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
void solve() {
    string s;
    cin >> s;
    int n = s.size();
    if(s.size() == 1 ){
        if(s[0] == '0') {
            cout << 0;
            return;
        }
    }
    reverse(all(s));
    string ans = "";
    bool ok = false;
    for(int i =0 ;i < n; i ++) {
        if(s[i] == '5') {
            ans.pb('2');
        }
        else if(s[i] == '2' ){
            ans.pb('5');
        }
        else {
            ans.pb(s[i]);
        }
    }
    for(auto i:ans) {
        if(i != '0') {
            ok = true;
        }
        if(ok)cout << i;
    }
    
}
signed main() {
#ifndef ONLINE_JUDGE
    // For getting input from input.txt file
    freopen("input.txt", "r", stdin);
    // Printing the Output to output.txt file
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int tt = 1;
   // cin >> tt;
    for (int q = 1; q <= tt; q++) {
        solve();
        cout << endl;
    }
}
