#include <bits/stdc++.h>
#define S second
#define F first
#define int long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define yes "YES\n"
#define no "NO\n"
#define ent "\n"
#define rv reverse
#define fr(i,x,y) for(int i = x;i <= y;i++)
#define frr(i,x,y) for(int i = x;i >= y;i--)
using namespace std;

const int mod = 1e9 + 7,maxn = 1e5 + 5;

void solve() {
	string s;
	cin>>s;
	rv(all(s));
	for(int i = 0;i < s.size();i++){
		if(s[i] == '0' && i == 0){
			continue;
		}
		if(s[i] == '2'){
			cout<<'5';
			continue;
		}
		if(s[i] == '5'){
			cout<<'2';
			continue;
		}
		else{
			cout<<s[i];
		}
	}
}

signed main() {
	//freopen ("bridges.in","r",stdin);
	//freopen ("bridges.out","w",stdout);
	ios_base::sync_with_stdio(0);
	int t = 1;
	//cin>>t;
	while(t--) {
		solve();
	}
}
