#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,k,i,a[10005],p;
main()
{
    string s;
    cin >> s;
    for(int i = 0; i < (int)s.size(); ++ i)
    {
        if(s[i] == '5')
        {
            s[i] = '2';
        }
        else if(s[i] == '2')
        {
            s[i] = '5';
        }
    }
    reverse(s.begin(), s.end());
    while(s[0] == '0')
    {
        s.erase(s.begin());
    }
    cout << s;
}
