#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << 39 << endl;
  int j = 19;
  while (j--) {
    int k = log2(n) + 1;
    n ^= (int)(pow(2, k) - 1);
    n++;
    cout << k << ' ';
  }
  cout << log2(n) + 1 << endl;
  return 0;
}
