#include "bits/stdc++.h"

using namespace std;

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

    int n = c.length();
    string ans = "";
    for (int i = n - 1;i >= 0;i--){
        if (c[i] == '2')
            ans += '5';
        else if (c[i] == '5')
            ans += '2';
        else
            ans += c[i];
    }

    bool flag = true;
    for (int i = 0;i < n;i++){
        if (flag and ans[i] == '0') continue;
        else if (ans[i] != '0'){
            cout << ans[i];
            flag = false;
        } else if (!flag) {
            cout << ans[i];
        }
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;

    while (t--) solve();
}
