#include <bits/stdc++.h>
using namespace std;

    typedef long long ll;
    typedef long double ld;

void solve() {
    string s;
    cin >> s;
    for (ll i = 0; i < s.size(); i++) {
        if (s[i] == '2') {
            s[i] = '5';
        } else {
            if (s[i] == '5') {
                s[i] = '2';
            }
        }
    }
    reverse(s.begin(), s.end());
    ll i = 0;
    while (s[i] == '0') {
        i++;
    }
    for (i; i < s.size(); i++) {
        cout << s[i];
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    int t = 1;
    //cin >> t;

    while (t--) {
        solve();
    }
}
