#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string n;
    cin >> n;
    reverse(n.begin(), n.end());
    for (int i = 0; i < n.size(); ++i){
        if (n[i] == '2') n[i] = '5';
        else if (n[i] == '5') n[i] = '2';
    }
    long long ans = stoll(n);
    cout << ans;
}
