#include <iostream>
#include <string>
using namespace std;
int main()
{
    string a;
    cin >> a;
    string itog;
    int size = a.size()-1;
    if (!a.empty() && a.back() == '0') 
    {
        a.pop_back();
    }
    for (char& c : a)
    {
        if (c == '2') 
        {
            c = '5';
        }
        else if (c == '5') 
        {
            c = '2';
        }
    }
    string reversed(a.rbegin(), a.rend());
    cout << reversed;
    
    
}
