#include using namespace std; typedef long long ll; typedef unsigned long ul; typedef unsigned long long ull; int factorial(int x) { if(x == 0) return 1; return x * factorial(x-1); } int main(void) { ios_base::sync_with_stdio(false); int facts[10]; for(int i = 0; i <= 9; i++) facts[i] = factorial(i); ull y; cin >> y; vector result; while(y > 0) { int id; for(int i = 9; i >= 0; i--) { if (facts[i] <= y) { y -= facts[i]; id = i; break; } } if(id == 1) id = 0; result.push_back(id); } if(result[result.size()-1] == 0) result[result.size()-1]=1; for(int i = result.size() - 1; i >= 0; i--) { cout << result[i]; } cout << endl; return 0; }