#define _CRT_SECURE_NO_WARNINGS #define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING #include using namespace std; typedef long long ll; inline ll lowbit(ll x) { return x & -x; } inline int log2ll(ll x) { int r = 0; for (; x; x >>= 1) r++; return r; } vector ans; void test(ll x, int i) { if (lowbit(x + 1) == x + 1) { cout << i << endl; for (int x : ans) cout << x << " "; exit(0); } } int main() { long long x; cin >> x; for (int i = 0; i < 40; i++) { if (i & 1) x++, test(x, i + 1); else { //char buf[1000]; //itoa(x, buf, 2); //printf("** %s\n", buf); test(x, i); ll pos = log2ll(lowbit(x)) - 1; ans.push_back(pos); x ^= (1 << pos) - 1; test(x, i + 1); //itoa(x, buf, 2); //printf("** %s\n", buf); } //cout << x << endl; } return 0; }