#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

signed main() {
    std::ios::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
    string s;
    cin >> s;
    string ans;
    for (auto c : s)
        ans += a[c];
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
        if (ans[i] != '0') {
            for (int j = i; j < ans.size(); j++)
                cout << ans[j];
            return 0;
        }
    }
}