#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

vector<vector<bool>> used;
vector<string> a(10);

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
   
    /*
    for (string& s : a) cin >> s;
       
    int a1 = 4, a2 = 3, a3 = 2, a4 = 1;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            if (!used[i][j] && a[i][j] == '#') {
                dfs(i, j);
            }
        }
    }
    */

    string s; cin >> s;
    for (char& c : s) {
        if (c == '2') {
            c = '5';
        }
        else if (c == '5') {
            c = '2';
        }
    }
    while (s.size() > 1 && s.back() == '0')
        s.pop_back();
    reverse(s.begin(), s.end());

    cout << s;
}