#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long;
using db = double;

void solve() {
	string s; cin >> s;
	while (s.back() == '0')s.pop_back();
	reverse(s.begin(), s.end());
	for (auto& c : s) {
		if (c == '2')c = '5';
		else if (c == '5')c = '2';
	}
	cout << s;
}

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