#include "bits/stdc++.h" typedef long long int ll; using namespace std; ll factorials [10] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; int main() { ll n = 0; cin >> n; list results; while (n > 0){ for (ll i = 9; i >= 0; --i) { if (n - factorials[i] >= 0) { n -= factorials[i]; results.push_front(i); break; } } } for (auto & i: results){ cout << i; } cout << endl; return 0; }