#include <bits/stdc++.h>
using namespace std;
long long a[1000001],b,c,n,m=-1,k,i,j;
string s,ss;
int main()
{
    cin >> s;
    ss=s;
    for(j=0,i=s.size()-1;j<s.size();j++,i--)
    {
        if(s[j]=='5') ss[i]='2';
        else if(s[j]=='2') ss[i]='5';
        else ss[i]=s[j];
        if(s[j]=='0' and m==-1) m=i;
        else if(s[j]!='0') m=-1;
    }
    ss.erase(0,m+1);
    cout << ss << endl;
    return 0;
}
