#include <bits/stdc++.h>
#include <set>
#include <vector>
#include <queue>
#include <map>
#include <string> 
 
#define pb push_back
#define ll long long
#define f first
#define s second

const ll int INF = 1e18, inf = 1e9, mod = 1e9 + 7;


using namespace std;



int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//setlocal(LC_ALL, "EN");
	map<char, int> mp {
		{'0', 0},
		{'1', 1},
		{'2', 5},
		{'3', 3},
		{'4', 4},
		{'5', 2},
		{'6', 6},
		{'7', 7},
		{'8', 8},
		{'9', 9}
	};
	string st;
	int l = 0;
	cin>>st;

	for (int i = st.size() - 1; i >= 0; i--) {
	    l *= 10;
		l += mp[st[i]];
	}

	cout<<l;
}
