#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#define aldgebu return
#define ff first
#define sc second
#define pb push_back
#define pii pair <int,int>
#define ll long long int
#define pll pair<ll,ll>
#define plc pair<ll,char>
#define ull unsigned long long
using namespace std;
const int inf = 1e9;
const int mod = 1000000007;



void Dontfuckedup(){
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	for (int i = 0; i < s.size(); i++){
		if (s[i] == '0' || s[i] == '1' || s[i] == '8')continue;
		if (s[i] == '6'){
			s[i] = '9';
			continue;
		}
		if (s[i] == '9')
			s[i] = '6';
	}
	cout << s;
}



int32_t main () {
 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int T = 1; //cin>>T;
    while (T--)Dontfuckedup();
 
    return 0;
}
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
	cin.tie(nullptr)->sync_with_stdio(false); 
	
	string s;
	cin >> s;

	cout << s[1] << s[2] << s[0] << endl;
}