#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main(){
    string a; cin >> a;
    reverse(a.begin(), a.end());

    for (int i = a[0] == '0'; i < a.length(); i++) {
        if (a[i] == '2') {
            cout << '5';
        }
        else if (a[i] == '5') {
            cout << '2';
        }
        else {
            cout << a[i];
        }
    }
}