#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[s.size()-1] == '0'){
        s.erase(s.end()-1, s.end());
    }
    long long n = s.size();
    for(long long i = s.size()-1; i >= 0; i--){
        if(s[i] == '5'){
            cout << "2";
        }
        else if(s[i] == '2'){
            cout << "5";
        }
        else{
        cout << s[i];
        }
    }
}
