#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define f first
#define s second
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) begin(x), end(x)
using namespace std;

const int N = 2e5 + 1, inf = LLONG_MAX / 2ll ;

void solve() {
    /*int n; cin >> n;
    set<ll> st;
    unordered_map<ll, int> cnt;
    for(int i = 0; i < n; i++) {
        ll x; cin >> x;
        st.insert(x);
        cnt[x]++;
    }
    bool ok = true;
    int m = 
    for()*/
    string s;
    cin >> s;
    while(!s.empty()&&s[sz(s) - 1] == '0') s.pop_back();
    reverse(all(s));
    for(int i = 0;i < sz(s);i++) {
        if(s[i] == '2') s[i] = '5';
        else if(s[i] == '5') s[i] = '2';
        cout << s[i];
    }
    return ;
}

signed main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);cout.tie(0);
    int T = 1 ;
    while (T--) {
        solve ( ) ;
    }
    return 0 ;
}