//============================================================================
// Author      : Bissenov Anuar
//============================================================================
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define run_faster ios::sync_with_stdio (false); cin.tie (0); cout.tie (0); ios_base::sync_with_stdio(0); cin.tie(nullptr);
#define F first
#define S second
#define emb emplace_back
#define pii pair<int,int>
#define all(v) (v.begin(),v.end())
#define rall(v) (v.rbegin(),v.rend())
using namespace std;

signed main()
{
    run_faster;
//	#ifndef ONLINE_JUDGE
//        freopen( "inverse.in" , "r" , stdin );
//        freopen( "inverse.out" , "w" , stdout );
//	#endif

    string s;
    string t;
    cin >> s;

    int n = s.size();
    bool z = 0;
    for( int i = n-1; i >= 0; i-- ) {
    	if( s[i] == '0' ) {
    		if( !z ) {
    			continue;
    		} else {
    			t += '0';
    		}
    	} else {
    		z = 1;
    		if( s[i] == '5') {
    			t += '2';
    		}
    		else if( s[i] == '2') {
    			t += '5';
    		}
    		else {
    			t += s[i];
    		}
    	}
    }
    cout << t;

    return 0;
} 
