#include <string>
#include <map>
#include <cstring>
#include <bitset>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <memory.h>
#include <list>
#include <vector>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <complex>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <numeric> // Include the numeric header for std::gcd()
#define ll long long
#define EL '\n'
using namespace std;
#define LL long long


#define PB push_back
#define MP make_pair
#define AA first
#define BB second
#define SZ size()
#define BG begin()
#define OP begin()
#define ED end()



using namespace std;

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

    string s;
    cin >> s;

    vector <int> reversed(s.size());

    for (int i = s.size() - 1; i >= 0; i--) {
        int ans = s[i] - '1' + 1;
    
        reversed[s.size() - 1 - i] = ans;
    }

    int j = 0;
    for (j; j < s.size(); j++) {
        if (reversed[j] != 0) {
            break;
        }
    }



    for (int i = j; i < s.size(); i++) {

            if (reversed[i] == 2) {
                cout << 5;
            }
            else if (reversed[i] == 5) {
                cout << 2;
            }
            else {
                cout << reversed[i];
            }
        
    }

    return 0;
}