#include "bits/stdc++.h" #define _CRT_SECURE_NO_WARNINGS #define rep(i,n) for(int i = 0;i < n;i++) #define REP(i,n,k) for(int i = n;i < k;i++) #define P(p) cout << (p) << endl; #define sP(p) cout << setprecision(15) << fixed << p << endl; #define Pi pair #define IINF 1e9 #define LINF 1e18 #define vi vector #define mp make_pair #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; int dx[] = { 0, 1, 0, -1 }; int dy[] = { -1, 0, 1, 0 }; unsigned long long sttoi(std::string str) { unsigned long long ret; std::stringstream ss; ss << str; ss >> ret; return ret; } ull gcd(ull a, ull b) { if (b > a)swap(a, b); if (b == 0) return a; return gcd(b, a%b); } int comb(int n,int k) { int ans = 1; for (int i = 0; i < min(k, n - k); i++) { ans *= n - i; ans /= i + 1; } return ans; } int pop[] = { 2,5,8,11,14,17,20,23 }; void solve() { int n; cin >> n; int sum = 0; int last; int digit; for (int i = 2; i < 25; i++) { last = sum; for (int j = 0; j < (sizeof(pop) / sizeof(int));j++) { if (i >= pop[j]) { sum += comb(i, pop[j]); } } if (n <= sum) { digit = i; break; } } int left = n - last; int ans = 0; for (int i = 0; i < (1 << digit); i++) { bool flag = false; int pops = 0; for (int j = 0; j < digit; j++) { if (i & 1 << j)pops++; } if ((pops + 1) % 3 == 0)flag = true; if (flag) { left--; if (left == 0){ ans = i; break; } } } string bit = ""; while (ans > 0) { char c = '0' + (ans & 1); bit = bit + c; ans >>= 1; } reverse(bit.begin(), bit.end()); while (bit.length() != digit) { bit = '0' + bit; } bit = bit + '1'; for (int i = 0; i < bit.length();i++) { if (bit[i] == '1') { bit[i] = '5'; } else if (bit[i] == '0') { bit[i] = '3'; } } P(bit); } int main() { solve(); return 0; }