#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s; cin >> s;
    int n = s.size(), f = 0;
    string scopy = "";
    for (int i=n-1; i>=0; i--) {
        if (f==0) {
            if (s[i] !='0') {
                f=1;
                if (s[i]=='2') {scopy += '5';}
                else if (s[i]=='5') {scopy +='2';}
                else {scopy+=s[i];}
            }
        } else {
            if (s[i]=='2') {scopy += '5';}
            else if (s[i]=='5') {scopy +='2';}
            else {scopy+=s[i];}
        }
    }
    cout << scopy;
    return 0;
}