#include <iostream>
#include <string>

#define endl '\n'

using namespace std;

int main()
{
    string s, res;
    cin >> s;
    int i = s.size()-1;
    while(s[i]=='0'){
        --i;
    }
    while(i>=0){
        if(s[i]=='2'){
            res+='5';
        }else if(s[i]=='5'){
            res+='2';
        }else{
            res+=s[i];
        }
        --i;
    }
    cout << (res == "" ? "0" : res) << endl;

    return 0;
}