#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <deque>

#ifndef Debug
#pragma GCC optimize("O3")
#endif

using ll = long long;

void bipkos() {
    std::string s;
    std::cin >> s;
    std::deque<ll> d;
    bool flg = true;
    for (int i = s.size() - 1; i >= 0; --i) {
        if(flg && s[i] == '0'){
            continue;
        }
        if(s[i] != '0'){
            flg = false;
        }
        d.push_back(s[i]);
    }
    for (int i = 0; i < d.size(); ++i) {
        if(d[i] == '5'){
            std::cout << 2;
        }
        else if(d[i] == '2'){
            std::cout << 5;
        }
        else{
            std::cout << d[i] - '0';
        }
    }
}

int main() {
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false);
    int t = 1;
//    std::cin >> t;
    while (t--) {
        bipkos();
    }
}
