#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    int i = s.size() - 1;
    while (s[i] == '0') {
        i--;
    }
    for (int j = i; j >= 0; j--) {
        if (s[j] == '2') {
            cout << 5;
        }
        else if (s[j] == '5') {
            cout << 2;
        }
        else {
            cout << s[j] - '0';
        }
    }
}