//#pragma GCC optimize("0fast")
//#pragma GCC optimize("popcnt, bm2")

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr); cout.tie(nullptr);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    long long k;
    cin >> k;
    long long ans = 0;
    while (k) {
        long long num = (k % 10LL);
        if (num == 2) {
            num = 5;
        }
        else if (num == 5) {
            num = 2;
        }
        ans *= 10;
        ans += num;
        k /= 10;
    }
    cout << ans;
    return 0;
}
