#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int inf = 1e9;
const long long llf = 1e18;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int x;
int a[30], len;
int main() {
  cin >> x;
  int ans[60], cnt = 0;
  while (1) {
    int flag = 1, ff = 0;
    for (int i = 20; i >= 0; i--) {
      int j = ((x >> i) & 1);
      if (j == 0 && ff == 0) {
        ans[++cnt] = i + 1;
        x ^= (1 << (i + 1)) - 1;
        ff = 1;
      } else if (j == 0) {
        cnt++;
        x++;
        flag = 0;
        break;
      }
    }
    if (flag) break;
  }
  cout << cnt << endl;
  for (int i = 1; i <= cnt; i += 2) cout << ans[i] << " ";
  return 0;
}
