#include<bits/stdc++.h>

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

using namespace std;

const int MAX = 2e5 + 7;

int n;
vector<int> a(MAX);

int main () {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
//    reverse(all(s));
    for (char &c : s) {
        if (c == '5')
            c = '2';
        else if (c == '2')
            c = '5';
    }
    while (sz(s) && s.back() == '0')
        s.pop_back();
    reverse(all(s));
    cout << s;
}
