#include<bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast") //~ only for that moment
#define all(x) (x).begin(), (x).end()
#define ImOnASugarCrash() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz(x) int((x).size())
template<typename... Args>
void read(Args&... args) {
    ((std::cin >> args), ...);
}
using ll = long long;
using ld = long double;
//!


signed main() {
    ImOnASugarCrash();
   	string k;
   	cin >>k;
   	for (int i = k.size() - 1; i >= 0; i --){
   		if (k[i] == '0' && i == k.size() - 1)
   			continue;
   		if (k[i] == '1')
   			cout <<1;
   		else if(k[i] == '0')
   			cout <<0;
   		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 if(k[i] == '9')
   			cout <<9;
   	}
}