#define _USE_MATH_DEFINES #include using namespace std; using ul = unsigned long long; using ll = long long; using ld = long double; using pll = pair; #define in(v,c) ((c).find(v) != (c).end()) #define F(i,n) for(ll i = 0; i < (n); i++) #define Fun(i,n) for(ul i = 0; i < (n); i++) #ifdef GPD templatevoid lerr(F&&f){cerr<(f)<void lerr(F&&f,R&&...r){cerr<(f)<<' ';lerr(forward(r)...);} #else #define lerr(...) #endif ll facts[10]; void count_facts(){ facts[0] = 1; for(int i = 1; i < 10; ++i){ facts[i] = facts[i-1] * i; } } int main(int argc, char const *argv[]) { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout << setprecision(9) << fixed; lerr("ready"); count_facts(); ll n; cin >> n; stack s; for(int i = 9; i>= 0 ; --i){ while(n - facts[i] >= 0){ n -= facts[i]; s.push(i); } } while(!s.empty()){ ll c = s.top(); s.pop(); cout << c; } cout << endl; return 0; }