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

#define pb push_back;

void solve() {
	string s, a;
	cin >> s;
	for (int i = s.size() - 1; i >= 0; --i) {
		if (a.size() == 0 and s[i] == '0') continue;
		if (s[i] == '2')
			a += "5";
		else if (s[i] == '5')
			a += "2";
		else
			a += s[i];
	}
	cout << a;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int T = 1;
//	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
