#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

ll comb[128][128];

void solve(ll N) {
  comb[0][0] = 1;
  REP(i,50) REP(j,50) {
    comb[i+1][j] += comb[i][j];
    comb[i+1][j+1] += comb[i][j];
  }
  // REP(i,20) { REP(j,20) cout << comb[i][j] << " "; cout << endl;}
  vector<tuple<ll,int,int,int,int>> vec;

  for (int i = 2; i < 50; ++i) {
    vec.emplace_back((1LL << (i - 1)) - 1, i, 0, 0, 0);
  }

  for (int i = 1; i < 25; ++i) {
    for (int j = 1; j < 25; ++j) {
      for (int ii = 1; ii < 5; ++ii) {
        for (int jj = 1; jj < 5; ++jj) {
          ll sum = (1LL << (i + j - 1)) - 1;
          sum += (1LL << (ii + jj - 1)) - 1;
          ll sum1 = 0, sum2 = 0;
          for (int k = 1; k <= i; ++k) {
            sum1 += comb[i][k] * comb[j][k];
          }
          for (int k = 1; k <= ii; ++k) {
            sum2 += comb[ii][k] * comb[jj][k];
          }
          sum += sum1 * sum2;
          vec.emplace_back(sum, i, j, ii, jj);
        }
      }
    }
  }

  sort(vec.rbegin(), vec.rend());
  // for (auto t: vec) cout << get<0>(t) << " " <<
  //                     get<1>(t) + get<2>(t) + get<3>(t) + get<4>(t) << endl;
  vector<int> res = { 1 };
  // for (int i = 2; i < 201; ++i) {
  //   for (int two = 50; two >= 2; --two) {
  //     ll c = (1LL << (two - 1)) - 1;
  //     if (N >= c) {
  //       REP(j,two) res.push_back(i);
  //       cout << two << endl;
  //       N -= c;
  //       break;
  //     }
  //   }
  // }
  for (int i = 2; i < 201; ++i) {
    for (auto t: vec) {
      ll num;
      int len1, len2, len3, len4;
      tie(num, len1, len2, len3, len4) = t;
      if (N >= num) {
        N -= num;
        if (len2 == 0) {
          REP(j,len1) res.push_back(i);
        }
        else {
          REP(j,len1) res.push_back(i);
          REP(j,len3) res.push_back(i + 1);
          REP(j,len2) res.push_back(i);
          REP(j,len4) res.push_back(i + 1);
          ++i;
        }
        // else if (ty == 1) {
        //   REP(j,len) res.push_back(i);
        //   res.push_back(i + 1);
        //   REP(j,len) res.push_back(i);
        //   res.push_back(i + 1);
        //   ++i;
        // }
        // else if (ty == 2) {
        //   REP(j,len) res.push_back(i);
        //   res.push_back(i + 1);
        //   res.push_back(i + 1);
        //   REP(j,ty) res.push_back(i);
        //   res.push_back(i + 1);
        //   res.push_back(i + 1);
        //   ++i;
        // }
        break;
      }
    }
  }
  cout << res.size() << endl;
  REP(i,res.size()) {
    cout << res[i] << " \n"[i == int(res.size()) - 1];
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	scanf("%lld", &N);
	solve(N);
	return 0;
}


Measured memory_bytes: 828