#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long mpow(long long a, long long x) {
  long long ret = 1;
  while (x) {
    if (x & 1) {
      ret *= a;
    }
    a *= a;
    ret %= 1000000007;
    a %= 1000000007;
    x >>= 1;
  }
  return ret % 1000000007;
}
long long find0(long long x) {
  long long cnt = 0;
  long long ans = -1;
  while (x > 0) {
    if ((x & 1) == 0) {
      ans = cnt;
    }
    cnt++;
    x = x >> 1;
  }
  return ans;
}
bool isdone(long long x) {
  if (((x) & (x + 1)) == 0) {
    return true;
  };
  return false;
}
void solveitcopymain() {
  long long n;
  cin >> n;
  long long turns = 0;
  std::vector<long long> an;
  while (isdone(n) != true) {
    if (turns % 2 == 0) {
      long long place = find0(n);
      an.push_back(place + 1);
      n ^= ((1LL << (place + 1)) - 1);
    } else {
      n += 1;
    }
    turns++;
  }
  cout << turns << endl;
  for (auto x : an) {
    cout << x << " ";
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long TCES;
  TCES = 1;
  for (long long undertale = 1; undertale <= TCES; undertale++) {
    solveitcopymain();
  }
  return 0;
}
