#include<bits/stdc++.h>
#define MAXINT 100000000
#define MAXV 10000000
using namespace std;
vector <pair<char,int>> a;
void init(){
    a.push_back({'0',6});
    a.push_back({'1',2});
    a.push_back({'2',5});
    a.push_back({'3',5});
    a.push_back({'4',4});
    a.push_back({'5',5});
    a.push_back({'6',6});
    a.push_back({'7',3});
    a.push_back({'8',7});
    a.push_back({'9',6});
}
string maxs(string& b, string& c){
    if(c[0] == '-'){
        return b;
    }
    if(b.size() > c.size()){
        return b;
    }
    if(c.size() > b.size()){
        return c;
    }
    for(int i = 0; i < c.size(); i++){
        if(b[i] > c[i]){
            return b;
        }
        if(c[i] > b[i]){
            return c;
        }
    }
    return b;
}
string dp[MAXV];
int n;
bool op[MAXV];
string f(int v){
    if(v == 0){
        return "0";
    }
    if(v < 0){
        return "-1";
    }
    if(op[v]){
        return dp[v];
    }
    op[v] = true;
    string ans = "0";
    for(int i = 0; i < 10; i++){
        string z = f(v-a[i].second);
        z += a[i].first;
        ans = maxs(ans, z);
    }
    dp[v] = ans;
    return ans;
}
int main(){
    cin >> n;
    init();
    for(int i = 1; i <= n; i++){
        f(n);
    }
    string z = f(n);
    reverse(z.begin(), z.end());
    z.pop_back();
    reverse(z.begin(), z.end());
    cout << z;
    return 0;
}
