#include <bits/stdc++.h>
using namespace std;
using ll = long long;
mt19937_64 rnd(time(0));
#define push_back pb
#define make_pair mp
#define F first
#define S second
#define all(x) x.begin(), x.end()

const ll N = 2e5 + 5;
const ll INF = 1e15;

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int ok = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] != '0') ok = 1;
        if (s[i] == '0' && ok)
            cout << 0;
        else if (s[i] == '0') continue;
        else if (s[i] == '2') cout << 5;
        else if (s[i] == '5') cout << 2;
        else cout << s[i];
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    solve();

    return 0;
}