#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

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

    cin >> s;

    string str;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '5')
            str += '2';
        else if (s[i] == '2')
            str += '5';
        else
            str += s[i];
    }

    ll i = 0;
    while (str[i] == '0')
        i++;
    for (int j = i; j < str.size(); j++)
        cout << str[j];

    return 0;
}
