#include <bits/stdc++.h>
using namespace std;
vector<int> moves;
vector<int> pows;
int get(int x, int dep = 0) {
  if (log2(x + 1) == (int)log2(x + 1)) {
    return dep;
  }
  if (dep >= 40) return -1;
  if (dep % 2) return get(x + 1, dep + 1);
  int idx = 0;
  while ((x & (1 << idx)) == 0) ++idx;
  int n = ((1 << idx) - 1);
  moves.push_back(idx);
  return get(x ^ n, dep + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  srand(time(NULL));
  for (int i = 0; i <= 30; ++i) pows.push_back(i);
  random_shuffle(pows.begin(), pows.end());
  int x;
  cin >> x;
  int ops = get(x);
  cout << ops << "\n";
  for (int i : moves) cout << i << " ";
  if (moves.size()) cout << "\n";
}
