#pragma GCC optimize("O3,unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define ull unsigned ll
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define fz(i,a,n,z) for(int i=a;i<n;i+=z)
#define rep(i,a,n,z) for(int i=a;i>n;i-=z)
#define faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file(name) freopen(name".inp","r",stdin);freopen(name".out","w",stdout);
const int N = 1e6 + 5;
void Bai1() {
int n;
cin >> n;
ll B[n + 5] = {};
for (ll i = 1; i <= n; ++i) {
cin >> B[i];
}
ll A[n + 5] = {}, T[n + 5] = {};
A[1] = B[1];
cout << A[1] << " ";
T[1] = A[1];
for (ll i = 2; i <= n; ++i) {
A[i] = B[i] * i - T[i - 1];
T[i] = T[i - 1] + A[i];
cout << A[i] << " ";
}
}
int main() {
faster
ll k;
cin >> k;
if (k == 1) {
cout << 5;
return 0;
}
if (k == 2) {
cout << 8;
return 0;
}
ll lt = 2, i = 1;
while (k >= lt) {
k -= lt;
lt *= 2;
++i;
}
if (k == 0) {
for (int j = 1; j < i; ++j) cout << 8;
return 0;
}
else {
--k; int d = 0;
string s = "";
while (k > 0) {
if (k % 2 == 1) s = '8' + s;
else s = '5' + s;
++d;
k /= 2;
}
for (int j = 1; j <= i - d; ++j) {
cout << 5;
}
cout << s;
}
}
/*-----------------------END-----------------------*/
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk8zLHVucm9sbC1sb29wcyIpCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSB1bGwgdW5zaWduZWQgbGwKI2RlZmluZSBzeih4KSAoaW50KSh4KS5zaXplKCkKI2RlZmluZSBhbGwoeCkgKHgpLmJlZ2luKCksKHgpLmVuZCgpCiNkZWZpbmUgZjAoaSxuKSBmb3IoaW50IGk9MDtpPG47aSsrKQojZGVmaW5lIGYxKGksbikgZm9yKGludCBpPTE7aTw9bjtpKyspCiNkZWZpbmUgZnooaSxhLG4seikgZm9yKGludCBpPWE7aTxuO2krPXopCiNkZWZpbmUgcmVwKGksYSxuLHopIGZvcihpbnQgaT1hO2k+bjtpLT16KQojZGVmaW5lIGZhc3RlciBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTtjaW4udGllKDApO2NvdXQudGllKDApOwojZGVmaW5lIGZpbGUobmFtZSkgZnJlb3BlbihuYW1lIi5pbnAiLCJyIixzdGRpbik7ZnJlb3BlbihuYW1lIi5vdXQiLCJ3IixzdGRvdXQpOwpjb25zdCBpbnQgTiA9IDFlNiArIDU7CnZvaWQgQmFpMSgpIHsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICBsbCBCW24gKyA1XSA9IHt9OwogICAgZm9yIChsbCBpID0gMTsgaSA8PSBuOyArK2kpIHsKICAgICAgICBjaW4gPj4gQltpXTsKICAgIH0KICAgIGxsIEFbbiArIDVdID0ge30sIFRbbiArIDVdID0ge307CiAgICBBWzFdID0gQlsxXTsKICAgIGNvdXQgPDwgQVsxXSA8PCAiICI7CiAgICBUWzFdID0gQVsxXTsKICAgIGZvciAobGwgaSA9IDI7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgQVtpXSA9IEJbaV0gKiBpIC0gVFtpIC0gMV07CiAgICAgICAgVFtpXSA9IFRbaSAtIDFdICsgQVtpXTsKICAgICAgICBjb3V0IDw8IEFbaV0gPDwgIiAiOwogICAgfQp9CmludCBtYWluKCkgewogICAgZmFzdGVyCiAgICBsbCBrOwogICAgY2luID4+IGs7CiAgICBpZiAoayA9PSAxKSB7CiAgICAgICAgY291dCA8PCA1OwogICAgICAgIHJldHVybiAwOwogICAgfQogICAgaWYgKGsgPT0gMikgewogICAgICAgIGNvdXQgPDwgODsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGxsIGx0ID0gMiwgaSA9IDE7CiAgICB3aGlsZSAoayA+PSBsdCkgewogICAgICAgIGsgLT0gbHQ7CiAgICAgICAgbHQgKj0gMjsKICAgICAgICArK2k7CiAgICB9CiAgICBpZiAoayA9PSAwKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPCBpOyArK2opIGNvdXQgPDwgODsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGVsc2UgewogICAgICAgIC0tazsgaW50IGQgPSAwOwogICAgICAgIHN0cmluZyBzID0gIiI7CiAgICAgICAgd2hpbGUgKGsgPiAwKSB7CiAgICAgICAgICAgIGlmIChrICUgMiA9PSAxKSBzID0gJzgnICsgczsKICAgICAgICAgICAgZWxzZSBzID0gJzUnICsgczsKICAgICAgICAgICAgKytkOwogICAgICAgICAgICBrIC89IDI7CiAgICAgICAgfQogICAgICAgIGZvciAoaW50IGogPSAxOyBqIDw9IGkgLSBkOyArK2opIHsKICAgICAgICAgICAgY291dCA8PCA1OwogICAgICAgIH0KICAgICAgICBjb3V0IDw8IHM7CiAgICB9CgoKfQovKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tRU5ELS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0qLwoK