
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    string a;
    cin >> a;
    while(a[a.size()-1] == '0') {
        a.pop_back();
    }
    for(auto& x : a) {
        if(x == '2') {
            x = '5'; 
        }
        else if(x == '5') {
            x = '2';
        }
    }
    reverse(a.begin(), a.end());
    cout << a;
}