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

signed main () {
    string s;
    cin >> s;
    
    reverse(s.begin(), s.end());
    char a[10];
    
    for (ll i=0; i<10; i++) a[i]=i+48;
    
    ll pos=0;
    while (s[pos]==a[0] && pos<s.length()) pos++;
    for (ll i=pos; i<s.length(); i++) {
        for (ll x=0; x<10; x++) {
            if (a[x]==s[i]) {
                if (a[x]=='5') cout << 2;
                else if (a[x]=='2') cout << 5;
                else cout << a[x];
            }
        }
    }
}