#include using namespace std; int main(){ int pos = 9, fac[10]; long long y; cin >> y; vector res; fac[0] = 1; for (int i=1; i<10; i++) fac[i] = i*fac[i-1]; if (y == 1){ cout << 0 << endl; } else{ while(y != 0){ while (fac[pos] > y) pos--; res.push_back(pos); y -= fac[pos]; } for (int i=res.size()-1; i>=0; i--) { cout << res[i]; cout.flush(); } cout << endl; /* __uint128_t resres = 0; for (int i=res.size()-1; i>=0; i--) { __uint128_t x = 1; for (int j = 0; j < i; j++) x *= 10; resres += res[i]*x; } // cout << resres << endl; */ } }