#include <bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    // freopen("prices.in", "r", stdin);
    // freopen("prices.out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int tests = 1;
//    cin >> tests;
    while (tests--){
        string s;
        cin >> s;
        map<char, char> mp;
        mp['1'] = '1';
        mp['2'] = '5';
        mp['3'] = '3';
        mp['4'] = '4';
        mp['5'] = '2';
        mp['6'] = '6';
        mp['7'] = '7';
        mp['8'] = '8';
        mp['9'] = '9';
        mp['0'] = '0';
        string ans;
        for(int i = s.size() - 1; i >= 0; i--)
        {
            if(i == s.size() - 1 && s[i] == '0') continue;
            else ans += mp[s[i]];
        }
        cout << ans;
    }
}
