#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
//#include <algorithm>
//#include <cmath>

using namespace std;
using ll = long long;

int main()
{
    /*string s; cin >> s;
    map <char, ll> a;
    a['0'] = 0;
    a['1'] = 1;
    a['2'] = 5;
    a['3'] = 3;
    a['4'] = 4;
    a['5'] = 2;
    a['6'] = 6;
    a['7'] = 7;
    a['8'] = 8;
    a['9'] = 9;
    for (ll i = s.size()-1; i >= 0; i++) {
        if (s[i] == '0' && i == s.size() - 1) {
            continue;
        }
        else {
            cout << a[s[i]];
        }
    }*/
    string s;
    cin >> s;
    int end = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '2') {
            cout << '5';
            end = 0;
        }
        else if (s[i] == '5') {
            cout << 2;
            end = 0;
        }
        else if (s[i] == '0') {
            if (end != 1)
            {
                cout << '0';
            }
        }
        else {
            cout << s[i];
        }

    }
};