#include <bits/stdc++.h>

#define mp make_pair
#define ull unsigned long long
#define ll long long
#define forn(i, n) for(int i = 0; i < n; i++)
using namespace std;

void start() {
    string s, s2;
    cin >> s;
    reverse(s.begin(), s.end());
    bool flag = true;
    forn(i, s.size()) {
        if (flag && s[i] == '0') continue;
        if (s[i] == '2') s[i] = '5';
        else if (s[i] == '5') s[i] = '2';
        flag = false;
        s2.push_back(s[i]);
    }

    cout << s2 << "\n";
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--)
        start();
}