#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll i;
    string s;
    cin >> s;
    ll m = s.size();
    for (i = m - 1; i >= 0; i --){
        if (s[i] == '2'){
            cout << 5;
        }
        else if (s[i] == '5'){
            cout << 2;
        }
        else if (s[i] == '0' and (i == m - 1) or (i == 0)){
            continue;
        }
        else {
            cout << s[i];
        }
    }



    return 0;
}
