#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define pb push_back
#define ll long long
using namespace std;
 
const ll N = 1e5 + 7;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
string s;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
 
    cin >> s;
    if (s[s.size() - 1] == '0') {
        s.erase(s.begin() + s.size() - 1);
    }
    for (int i = s.size() - 1; i >= 0; --i) {
        if (s[i] == '5') cout << '2';
        else if (s[i] == '2') cout << '5';
        else cout << s[i];
    }
 
}