1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
pref = [0]
mx = 1 << 18
for i in range(1, mx):
	pref.append(pref[-1] + bin(i).count("1"))

n = int(input())
res = []

for i in range(mx-1, 0, -1):
	if pref[i-1] < n:
		n -= bin(i).count("1")
		res.append(str(i))

print(len(res))
print(' '.join(res))