#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long a;     cin >> a;     bitset<22> b(a);     long long i, j, k;     long long c = 0;     vector<long long> v;     for (i = 0; i <= 40; i++) {       long long temp = a;       temp++;       if ((a & temp) == 0) {         break;       }       if (i % 2)         a++;       else {         bitset<22> z(a);         for (j = 21; j >= 0; j--) {           if (z[j] == 1) break;         }         for (; j >= 0; j--)           if (z[j] == 0) break;         v.push_back(j + 1);         a = a ^ (long long)(pow(2, j + 1) - 1);       }     }     cout << i << endl;     for (auto g : v) cout << g <<    ;     cout << endl;   }   