#include #include #include #include using lint = long long; void solve() { int n; std::cin >> n; --n; for (int m = 1;; ++m) { std::vector ss; for (int b = 0; b < (1 << m); ++b) { if ((b & 1) == 0 || __builtin_popcount(b) % 3 != 0) continue; std::string s(m, '$'); for (int j = 0; j < m; ++j) s[j] = "35"[(b >> j) & 1]; std::reverse(s.begin(), s.end()); ss.push_back(s); } int k = ss.size(); if (k <= n) { n -= k; continue; } std::sort(ss.begin(), ss.end()); std::cout << ss[n] << "\n"; return; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }