#include <iostream>

using namespace std;

int main () {
    int des[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    int curNum = 0, g = 0, curS = 0, N;
    cin >> N;
    if ( N < 0 || N > 10000000) return 0;
    for ( int m = 0; m < 10; m ++) {
        for ( int i = 0; i < 9; i ++) {
            for ( int n = 0; n < 10; n ++ ) {
                curNum = 100 * m + 10 * i + n;
                if ( m == 0 ) curS = des[i] + des[n];
                else curS = des[m] + des[i] + des[n];
                if (curS == N) g = curNum;
            }
        }
    }
    if (!g) cout << -1 << endl;
    else cout << g << endl;
    return 0;
}
