#include<bits/stdc++.h>
using namespace std;
int main()
{
	string k;
	cin >> k;
	vector<char>v(k.size());
	for (int i = 0; i < k.size(); ++ i)
	{
		if (k[i] == '2')
			v[i] = '5';
		else if (k[i] == '5')
			v[i] = '2';
		else
			v[i] = k[i];
	}
	reverse(v.begin(), v.end());
	int i = 0;
	while(v[i] == '0') ++i;
	while(i<k.size()) {
		cout <<v[i];
		++i;
	}
	cout << endl;
return 0;
}