#include <iostream>

using namespace std;
int a[100], h = 0, g = 0;
long long n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    while(n != 0)
    {
        a[++h] = n % 10;
        n /= 10;
    }
    for(int i = 1; i <= h; i++)
    {
        if(a[i] == 2) a[i] = 5;
        else if(a[i] == 5) a[i] = 2;
    }
    for(int i = 1; i <= h; i++)
    {
        if(a[i] != 0) 
        {
            g = 1;
            cout << a[i];
        }
        else if(a[i] == 0 && g == 1)
            cout << a[i];
    }
    return 0;
}