#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <cassert>
#include <random>
#include <chrono>
#include <tuple>

#pragma GCC optimize("03")
#pragma GCC target("avx2")

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ii = int;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll ans = stoll(s);
    string anss = to_string(ans);
    for (auto c : anss) {
        if (c == '5') {
            c = '2';
        }
        else if (c == '2') {
            c = '5';
        }
        cout << c;
    }
    return 0;
}
