#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s = "";
  while (n != 0) {
    s = (char)(n % 2 + 48) + s;
    n /= 2;
  }
  vector<int> v;
  int k = s.size();
  if (s[k - 1] == '1') {
    char ch = '0';
    for (int i = 0; i < k; i++) {
      if (s[i] == ch) {
        v.push_back(k - i);
        ch = (ch == '0') ? '1' : '0';
      }
    }
    cout << v.size() * 2 << endl;
    for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  } else {
    v.push_back(1);
    for (int i = s.size() - 2; i >= 0; i--) {
      if (s[i] == '0') {
        v.push_back(s.size() - i - 1);
      }
    }
    cout << v.size() * 2 - 1 << endl;
    for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  }
}
int main() {
  solve();
  return 0;
}
