import java.io.*;
import java.util.*;

public class cave_ak {
    public static void main(String[] args) throws FileNotFoundException {
        int n = new Scanner(new FileReader("cave.in")).nextInt();
        int[] prev = new int[1 << n];
        Arrays.fill(prev, -1);
        prev[0] = -2;
        Queue<Integer> q = new ArrayDeque<>();
        q.add(0);
        while (!q.isEmpty()) {
            int v = q.poll();
            int t = v ^ 1;
            if (prev[t] == -1) {
                prev[t] = v;
                q.add(t);
            }

            int first = Integer.lowestOneBit(v);
            if (first == (1 << (n - 1))) {
                continue;
            }
            t = v ^ (first << 1);
            if (prev[t] == -1) {
                prev[t] = v;
                q.add(t);
            }
        }

        ArrayList<Integer> path = new ArrayList<>();
        int v = (1 << n) - 1;
        while (v != -2) {
            path.add(v);
            v = prev[v];
        }
        Collections.reverse(path);

        PrintWriter out = new PrintWriter("cave.out");
        out.println(path.size() - 1);
        for (int i = 0; i < path.size() - 1; i++) {
            int from = path.get(i);
            int to = path.get(i + 1);
            if (to > from) {
                out.print(Integer.numberOfTrailingZeros(to ^ from) + 1 + " ");
            } else {
                out.print(-(Integer.numberOfTrailingZeros(to ^ from) + 1) + " ");
            }
        }
        out.println();
        out.close();
    }
}
