#include <bits/stdc++.h>
using namespace std;
long long n, m, q, a, b, c, i, h, j, k, l, sum, cnt, ans;
string s;
vector<long long> v;
int main() {
  cin >> n;
  while (1) {
    m = n;
    i = -1, j = 0;
    while (m) {
      if (m % 2 == 0) i = j;
      m /= 2;
      j++;
    }
    if (i == -1) break;
    if (k % 2)
      n++, k++;
    else {
      v.push_back(i + 1);
      m = (1 << (i + 1)) - 1;
      n = n ^ m;
      k++;
    }
  }
  cout << k << endl;
  for (auto a : v) cout << a << ' ';
}
