#include <iostream>
#include <vector>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")

long long getrev(long long n) {
    if (n == 5) return 2;
    if (n == 2) return 5;
    return n;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    long long n;
    cin >> n;
    vector<long long> nlist;
    while (true) {
        nlist.push_back(getrev(n % 10));
        n /= 10;
        if (n == 0) break;
    }

    long long ans = 0;
    for (auto i : nlist) {
        ans *= 10;
        ans += i;
    }
    cout << ans;
    return 0;
}
