#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

const long long mod = 1000000007, mod3 = 998244353, inf = (ll)1e15;

struct T{
    ll x, y;
};

ll n;

ll k, a[1000005], b[1000005];

string s;

void query(){
    cin >> s;

    reverse(all(s));

    while(s[0] == '0') s.erase(0, 1);

    for (ll i = 0; i < s.size(); i++){
        if (s[i] == '2') s[i] = '5';
        else if (s[i] == '5') s[i] = '2';
    }

    cout << s;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    ll TT = 1;

    //cin >> TT;

    while(TT--){
        query();
    }

    return 0;
}

/**

*/
