#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <bitset>
#include <map>
#include <algorithm>
#include <cmath>

using ll = long long;
template<typename T>
bool rMin(T& a, const T& b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool rMax(T& a, const T& b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

using namespace std;

map<char, char> dd = {
        {'0', '0'},
        {'1', '1'},
        {'2', '5'},
        {'3', '3'},
        {'4', '4'},
        {'5', '2'},
        {'6', '6'},
        {'7', '7'},
        {'8', '8'},
        {'9', '9'},
};

void solve(){
    string a;
    cin >> a;
    while(a.back() == '0') a.pop_back();
    reverse(a.begin(), a.end());
    for(auto &i : a) i = dd[i];
    cout << a;
}

int main(){
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;

    //cin >> t;

    for(int i = 0; i < t; ++i){
        solve();
    }
}