#include using namespace std; #define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l)) #define FORD(i, j, k, l) for(int i =(j); i >= (k); i -= (l)) #define REP(i, n) FOR(i, 0, n, 1) #define REPD(i, n) FORD(i, n, 0, 1) typedef long long ll; const ll INFF = (ll)1e18; const int INF = (int)1e9; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; vector fact(10); fact[0] = 1; for (int i = 1; i < 10; i++) { fact[i] = i * fact[i-1]; } int ptr = 9; vector ans; while(n) { if (ptr == 1) ptr--; if (n >= fact[ptr]) { ans.push_back(ptr); n -= fact[ptr]; } else { ptr--; } } sort(ans.begin(), ans.end()); bool lead = true; for (auto a : ans) { if (!a && lead) { cout << 1; lead = false; continue; } lead = false; cout << a; } cout << endl; return 0; }