#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
void solve(){
	ll n; cin >> n;
	string res = to_string(n);
	reverse(res.begin(), res.end());
	ll cur = stoll(res);
	string ans = to_string(cur);
	for(auto to : ans){
		if(to == '2') cout << 5;
		else if(to == '5') cout << 2;
		else cout << to;
	}
}
int main (){
	int test = 1; //cin >> test;
	while(test--) solve(), cout << "\n";
}
