#include <bits/stdc++.h>
using namespace std;
bool checkbits(bitset<32> x) {
  for (int i = 0; i < 32; i++)
    if (x[i] != 1) {
      int j = i + 1;
      while (j < 32 && x[j] != 1) j++;
      if (j == 32)
        return true;
      else
        return false;
    }
  return true;
}
int left0(bitset<32> x) {
  int r = 31;
  while (r >= 0 && x[r] != 1) r--;
  while (r >= 0 && x[r] != 0) r--;
  return r;
}
int main() {
  int x;
  cin >> x;
  bitset<32> bits = x;
  bool r = true;
  vector<int> v;
  int t = 0;
  while (!checkbits(x)) {
    if (t % 2 == 1)
      x++;
    else {
      int r = left0(x);
      int e = 1 << (r + 1);
      x = x ^ e - 1;
      v.push_back(r + 1);
    }
    t++;
  }
  cout << t << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
  return 0;
}
