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

#define ll long long
#define int ll

main()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    while(n && s[n - 1] == '0'){
        n--;
    }
    string t;
    for(int i = 0;i < n;i++){
        t += s[i];
    }
    reverse(t.begin(),t.end());
    for(int i = 0;i < n;i++){
        if(t[i] == '5') t[i] = '2';
        else if(t[i] == '2') t[i] = '5';
    }
    cout << t;
}