#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int mod = (int)1e9 + 7;
using namespace std;
long long p[50];
bool check(long long x) {
  for (int i = 0; i < 40; i++)
    if (p[i] - 1 == x) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long x, y;
  cin >> x;
  for (int i = 0; i < 40; i++) {
    p[i] = (1ll << i);
  }
  vector<int> ans;
  int cnt = 0;
  while (!check(x)) {
    y = x;
    cnt = 0;
    while (!(y & 1)) {
      y >>= 1;
      cnt++;
    }
    ans.push_back(cnt);
    x = x ^ (p[cnt] - 1);
    if (check(x)) break;
    x += 1;
    ans.push_back(1);
  }
  cout << ((int)ans.size()) << "\n";
  for (int i = 0; i < (int)ans.size(); i += 2) cout << ans[i] << " ";
  return 0;
}
