#include<iostream>
using namespace std;
int c[10];
string dp[10000001];
string maxx(string s1, string s2){
    if(s1.size() > s2.size())return s1;
    if(s2.size() > s1.size())return s2;
    int n = s1.size();
    for(int i = 0; i < n; i++){
        if(s1[i] > s2[i])return s1;
        if(s2[i] > s1[i])return s2;
    }
    return s1;
}
string f(int k){
    //cout << k << endl;
    if(k == 0)return "";
    if(dp[k] != "")return dp[k];
    string ans;
    for(int i = 0; i < 10; i++){
        if(c[i] <= k){
            char l = i + '0';
            ans = maxx(f(k - c[i]) + l, ans);
        }
    }
    dp[k] = ans;
    return ans;
}
int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    c[0] = 6;
    c[1] = 2;
    c[2] = 5;
    c[3] = 5;
    c[4] = 4;
    c[5] = 5;
    c[6] = 6;
    c[7] = 3;
    c[8] = 7;
    c[9] = 6;
    unsigned long long n;
    cin >> n;
    cout << f(n) << endl;

    return 0;
}
