// Bismi ALlah
#include "bits/stdc++.h"

using namespace std;

#define int long long


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