#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long 
#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const int MAXN=2*1e5+7;
int a[MAXN];


void solve(ll test_case)
{
    string s;
    cin>>s;
    int sz=s.size()-1;
    for(int i=sz;i>=0;i--)
    {
        if(i==sz&&s[i]=='0')
        {
            continue;
        }
        if(s[i]=='2')
        {
            cout<<5;
        }
        else if(s[i]=='5')
        {
            cout<<2;
        }
        else
        {
            cout<<s[i];
        }
    }
    

}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t, t1 = 0;
    t=1;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
}