#include #include using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long y; vector res; long long fact[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; cin >> y; for (long long i = 9; i >= 0; --i) { while(y >= fact[i]){ y -= fact[i]; res.push_back(i); } } sort(res.begin(), res.end()); for (int i = 1; i < res.size(); ++i) { if(res[i] == 1) res[i] = 0; } if (res.size() == 1 && res[0] == 1) cout<<0<