#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main()
{
    map<char, string> nums;
    nums['5'] = "2";
    nums['2'] = "5";
    nums['1'] = "1";
    nums['3'] = "3";
    nums['4'] = "4";
    nums['6'] = "6";
    nums['7'] = "7";
    nums['8'] = "8";
    nums['9'] = "9";
    nums['0'] = "0";
    string str;
    cin>>str;
    int a =0;
    string otv;
    reverse(str.begin(), str.end());
    for(int i = 0; i<=str.length();i++){
        if(str[i]!='0'){
            a+=1;
        }
        if(a != 0){
            otv += nums[str[i]];
        }
    }
    cout<<otv;
    return 0;
}

