import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

ulong[] units = [ 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535,
131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431,
67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, 4294967295,
8589934591, 17179869183, 34359738367, 68719476735, 137438953471, 274877906943,
549755813887, 1099511627775, 2199023255551, 4398046511103 ];

void main(){
	ulong n = read.to!ulong;
	
	int[] xs = [];
	ulong tempsum = 0;
	while(tempsum < n){
		int x = 0;
		while(units[x + 1] <= n - tempsum) x ++;
		xs ~= x;
		tempsum += units[x];
		}
	
	debug xs.writeln;
	
	int[] ans = [];
	foreach(i, x; xs){
		for(int j = 0; j < 2 + x; j ++) ans ~= i + 1;
		}
	
	ans.length.writeln;
	ans.map!(to!string).join(" ").writeln;
	
	}




string read(){
	static string[] ss;
	while(!ss.length) ss = readln.chomp.split;
	string res = ss[0];
	ss.popFront;
	return res;
	} 
