#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = s.length();
    string result = "";
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '2') {
            result += '5';
        } else if (s[i] == '5') {
            result += '2';
        } else {
            result += s[i];
        }
    }
    int startIndex = 0;
    for (int i = 0; i < result.length(); i++) {
        if (result[i] != '0') {
            break;
        }
        startIndex++;
    }
    result = result.substr(startIndex);
    if (result.empty()) {
        result = "0";
    }
    cout << result << endl;
}

