#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define F first
#define S second
using namespace std;
const int SIZE = 2e5 + 5;
const ll mod = 1e9 + 7;

void solve() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '5') {
            s[i] = '2';
        }
        else if (s[i] == '2') {
            s[i] = '5';
        }
    }
    int pos = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] >= '1' && s[i] <= '9') {
            pos = i;
            break;
        }
    }
    s = s.substr(pos);
    cout << s;
    return;
}

int main() {
    speed;

	int TIME;
	TIME = 1;
	//cin >> TIME;
	while (TIME-- > 0) {
		solve();
		cout << "\n";
	}
	return 0;
}
