#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);
#define tie cin.tie(0);
  
using namespace std;
template < class T > T emin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T emax(T &a,T b) {if (a < b) a = b;return a;}

int n;
const int a[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(){
    IOS tie
    cin >> n;
    int val = 1, cnt = 0;
    while (val <= n)
    {
        val *= 2;
        cnt++;
    }
	    cout << cnt + 1<< "\n";
    for (int i = 0; i < cnt - 1; i++) cout << a[i] << " ";
    cout << (a[cnt - 1] | ((1 << cnt) - n + 1));
}