# include <bits/stdc++.h>
# define flash ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
# define ff first
# define ss second
# define pb push_back
# define all(x) x.begin(), x.end()
# define allr(x) x.rbegin(), x.rend()
# define in insert
# define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)

typedef long long ll;
typedef double db;
typedef long double ld;
using namespace std;

const int N = 2e5 + 5;
const ll inf = 1e9 + 7;
const ll INF = 1e18;
const db pi = acos(-1.0);

ll tt=1, n;
string s;

void solve(){
	cin >> s;
	reverse(s.begin(),s.end());
	for(int i=0; i<s.size(); i++){
		if(i==0){
			while(s[i]=='0'){
				i++;
			}
			if(i==s.size()){
				cout << '0';
			}
		}
		if(s[i]=='5')
			cout << '2';
		else if(s[i]=='2')
			cout << '5';
		else
			cout << s[i];
	}
}

int main (){
	//file(s);
	flash;
	//cin >> tt;
	while (tt--){
		solve();
	}
	return 0;
}

