#include <iostream>
#include <vector>
#include <map>
#include<string>

using ll = long long;
using namespace std;

int main() {
    std::string s;
    std::cin >> s;
    reverse(s.begin(), s.end());
    bool flag = true;
    for (int i = 0; i < (int)s.size(); ++i) {
        if (flag and s[i] == '0') {
            continue;
        }
        flag = false;
        if (s[i] == '2') {
            std::cout << 5;
        }
        else if (s[i] == '5') {
            std::cout << 2;
        }
        else {
            std::cout << s[i];
        }
    }
    return 0;
}