#include <bits/stdc++.h>
using namespace std;
int lowb(int x) { return x & (-x); }
int step[41];
int main() {
  int a, i;
  scanf("%d", &a);
  int cnt = 0, ans = 0;
  int tt = a;
  if (lowb(a + 1) == a + 1) {
    printf("0");
    return 0;
  }
  while (lowb(tt) != tt) {
    int tmp = lowb(tt);
    int tcnt = 0;
    while (tmp > 1) tcnt++, tmp >>= 1;
    step[cnt++] = tcnt;
    ans += 2;
    tt += lowb(tt);
  }
  int tmp = lowb(tt);
  int tcnt = 0;
  while (tmp > 1) tcnt++, tmp >>= 1;
  step[cnt++] = tcnt;
  printf("%d\n", ans + 1);
  for (i = 0; i < cnt; i++) printf("%d ", step[i]);
  return 0;
}
