1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
n = int(input())
x = 0
i = 1
strengths = {}
while x < n:
    s = str(bin(i))[2:].count('1')
    strengths[i] = s
    x += s
    i += 1


excludes = []
c = i - 1
m = c

while x != n:
    if x - strengths[c] >= n:
        excludes.append(c)
        x -= strengths[c]
    else:
        c -= 1

print(m - len(excludes))
for i in reversed(range(m)):
    if i + 1 not in excludes:
        print(i + 1, end=' ')