import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] def make_divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] def f(x): L = make_divisors(x) return sum(L) def f2(x): return pow(2,x) def prime_factorize(n): ret = [] #if n == 1: # ret.append((1,1)) # return ret cnt = 0 while n % 2 == 0: cnt += 1 n //= 2 if cnt > 0: ret.append((2,cnt)) i = 3 while i * i <= n: cnt = 0 while n % i == 0: cnt += 1 n //= i else: if cnt != 0: #cnt==0の時は追加しない ret.append((i,cnt)) i += 2 if n != 1: ret.append((n,1)) return ret #(素因数、何乗) def check(x): L = prime_factorize(x) if len(L) == 1 and L[0][1] == 1: return True else: return False def main(): N = int(input()) if N == 0: print(1) print(-1);exit() if N == 1: print(1) print(1);exit() if N == 2: ans = [1,1] print(2) print(*ans);exit() for i in range(20): temp = pow(2,i+1) - 1 if temp == N: print(1) print(pow(2,i)) exit() X = N-1 while True: if check(X): break else: X += 1 N ^= (X+1) #print("N",N,"X",X) L = [] P = 15 pre = 0 for i in reversed(range(P)): if (N>>i)&1 == pre: continue L.append(i) pre = pre^1 #print(L) ans = [f2(x) for x in L] + [X] print(len(ans)) print(*ans) exit() v = 0 for a in ans: v ^= f(a) print(v) if __name__ == '__main__': main()