#include <bits/stdc++.h>
#define int long long
using namespace std;
int i;
string s;

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> s;
	while (!s.empty() && s.back() == '0') {
		s.pop_back();
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '2') s[i] = '5';
		else if (s[i] == '5') s[i] = '2';
	}
	reverse(s.begin(), s.end());
	cout << s;
}