#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define int long long
#define ll long long
#define con continue
#define fir first
#define sec second
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define rev reverse
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define endl "\n"
using namespace std;
void sad()
{
    string s,a;
    cin>>s;
    a="";
    int n=s.size();
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='0'&&a.size()==0)
        {
            con;
        }
        else
        {
            if(s[i]=='5')
            {
                a+='2';
            }
            else
            {
                if(s[i]=='2')
                {
                    a+='5';
                }
                else
                {
                    a+=s[i];
                }
            }
        }
    }
    cout<<a<<endl;
}
main()
{
    ll t = 1;
    //cin >> t;
    while (t--){
        sad();
    }
}
