#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    string k; cin >> k;
    string ans = "";
    for (int i = k.size() - 1; i >= 0; i--) {
        if (k[i] == '2') {
            ans += "5";
        }
        else if (k[i] == '5') {
            ans += "2";
        }
        else ans += k[i];
    }
    while (ans[0] == '0') {
        ans = ans.substr(1, ans.size() - 1);
    }
    cout << ans;
    return 0;
}