#include<iostream>
using namespace std;
int c[10];
int dp[10000001];
int f(int k){
    if(k == 0)return 0;
    if(k < 0)return -1;
    if(dp[k] != 0)return dp[k];
    int ans = 0;
    for(int i = 0; i < 10; i++){
        if(c[i] <= k){
            ans = max(f(k - c[i]) * 10 + i, 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;
    int n;
    cin >> n;
    cout << f(n) << endl;

    return 0;
}
