N = int(input()) import sys if N == 0: print(-1) exit() if N == 1: print(1) exit() ans = [] k = N.bit_length() ans.append(1 << (k-1)) now = (1 << k) - 1 for i in range(k-1,-1,-1): mask = 1 << i if now & mask and N & mask == 0: ans.append(mask) now ^= mask elif now & mask == 0 and N & mask: ans.append(mask) now ^= mask print(len(ans)) print(*ans)