#include <bits/stdc++.h>
#define ll long long
// #define int ll
#define pii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define in insert
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define deb(x) cout << #x << " = " << x << '\n';
#define file(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
using namespace std;

// const int dx[] = {0, 1, 0, -1};
// const int dy[] = {1, 0, -1, 0};

const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;



void solve() {
 string k; 
 cin >> k; 
 while(!k.empty() && k.back() == '0') { 
  k.pop_back(); 
 } 
 for(int i = sz(k) - 1; i >= 0; i--) { 
  if(k[i] == '0') cout << k[i]; 
  else if(k[i] == '1') cout << k[i]; 
  else if(k[i] == '2') cout << '5'; 
  else if(k[i] == '3') cout << '3'; 
  else if(k[i] == '4') cout << '4'; 
  else if(k[i] == '5') cout << '2'; 
  else if(k[i] == '6') cout << 6; 
  else if(k[i] == '7') cout << 7; 
  else if(k[i] == '8') cout << '8'; 
  else cout << 9; 
 }
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int TT = 1;
	// cin >> TT;
	while(TT--) {
		solve();
	}
	return 0;
}