#include int f(int x) { int res = 1; for(int i = 2; i < x + 1; i++){ res*=i; } return res; } int main(){ int facts[10]; for(int i = 0; i <= 9; i++){ facts[i] = f(i); // printf("%d ", facts[i]); } int y; scanf("%d", &y); int res[100000]; //change it later int n = 0; while(y){ for(int i = 9; i >= 0; i--){ if(y - facts[i] >= 0){ res[n] = i; y -= facts[i]; i = -1; n++; } } } for(int i = n - 1; i >= 0; i--){ printf("%d", res[i]); } return 0; }