#include<bits/stdc++.h>

// defs
#define SMAGULOV ios_base::sync_with_stdio(0); cin.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
// end of defs

using namespace std;
int main(){
SMAGULOV;

string k; cin >> k;

reverse(k.begin(), k.end());
bool bl = 1;
	for(int i = 0; i < k.size(); i++){
		if(bl and k[i] == '0'){
			continue;
		}
		else if(k[i] != '0'){
			bl = 0;
		}
		if(k[i] == '5'){
			k[i] = '2';
		}
		else if(k[i] == '2'){
			k[i] = '5';
		}
		cout << k[i];
	}
}