#include #include #include using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) int comb[40][40]; int main() { int N; cin >> N; comb[0][0] = 1; rep(i, 40-1) { comb[i+1][0] = 1; rep(j, 40-1) comb[i+1][j+1] = comb[i][j] + comb[i][j+1]; } int tmp = 0; rep(i, 30) { int n = i + 2; int tmp2 = 0; for (int k = 2; n >= k; k += 3) tmp2 += comb[n][k]; tmp += tmp2; if (tmp < N) continue; tmp -= tmp2; n = 2; rep(i, N - tmp) { ++n; while (__builtin_popcount(n) % 3 != 2) ++n; } vector ans; for (; n > 0; n /= 2) ans.push_back(n % 2); while ((int)ans.size() < i+2) ans.push_back(0); reverse(ans.begin(), ans.end()); for (const auto& e : ans) cout << (e == 0 ? 3 : 5); cout << 5 << endl; return 0; } return 0; }