1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
target = int(input())
def get_bits(i):
    return bin(i).count("1")

i = 1
total = 0
result = []
while total < target:
    result.append(i)
    total += get_bits(i)
    i += 1

result.reverse()

if total > target:
    diff = total - target
    for item in result:
        if get_bits(item) == diff:
            result.remove(item)
            break

print(len(result))
result = " ".join(map(str, result))
print(result)