#include <bits/stdc++.h>
#define first f
#define second s

using namespace std;

long long  a,b , i, j,n,m,k,q,border;
string s,s1;
int main()
{
    cin>>s;
    s1.resize(s.size());

    for(long long i=s.size()-1;i>=0;i--){
        if(s[i]=='0') border=s.size()-i-1;
        if(s[i]!='0') { border=s.size()-(s.size()-(i+1))-1;
                break;}
    }
    //cout<<border<<endl;
    for(long long i=border;i>=0;i--){

        s1[q]=s[i],q++;
        if( q>0 and s1[q-1]=='5') {s1[q-1]='2';
        continue;}
        if( q>0 and s1[q-1]=='2') {s1[q-1]='5';
        continue;}
    }
    cout<<s1;
    //for(long long i=0;i<s1.size();i++)cout<<s1;
    return 0;
}
