#include<bits/stdc++.h>
#define MAXINT 1000000000
using namespace std;
vector <pair<int,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});
}
int f(int v){
    if(v == 0){
        return 0;
    }
    if(v < 0){
        return -MAXINT;
    }
    int ans = 0;
    for(int i = 0; i < 10; i++){
        ans = max(ans, f(v-a[i].second)*10 + a[i].first);
    }
    return ans;
}
int main(){
    int n;
    cin >> n;
    init();
    cout << f(n);
    return 0;
}
