#include <bits/stdc++.h>
#define ent '\n'
#define f first
#define s second

using namespace std;
typedef long long ll;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;

ll n , m , k;

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

int main(){ 
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int i = 1;i <= T;i++){
        solve();
    }
}
