Problem: Cat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.

Assume that we have a cat with a number x. A perfect longcat is a cat with a number equal 2^m - 1 for some non-negative integer m. For example, the numbers 0, 1, 3, 7, 15 and so on are suitable for the perfect longcats.

In the Cat Furrier Transform, the following operations can be performed on x:

  * (Operation A): you select any non-negative integer n and replace x with x ⊕ (2^n - 1), with ⊕ being a [bitwise XOR operator](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
  * (Operation B): replace x with x + 1. 



The first applied operation must be of type A, the second of type B, the third of type A again, and so on. Formally, if we number operations from one in the order they are executed, then odd-numbered operations must be of type A and the even-numbered operations must be of type B.

Neko wants to produce perfect longcats at industrial scale, thus for each cat Neko only wants to perform at most 40 operations. Can you help Neko writing a transformation plan?

Note that it is not required to minimize the number of operations. You just need to use no more than 40 operations.

Input

The only line contains a single integer x (1 ≤ x ≤ 10^6).

Output

The first line should contain a single integer t (0 ≤ t ≤ 40) — the number of operations to apply.

Then for each odd-numbered operation print the corresponding number n_i in it. That is, print ⌈ t/2 ⌉ integers n_i (0 ≤ n_i ≤ 30), denoting the replacement x with x ⊕ (2^{n_i} - 1) in the corresponding step.

If there are multiple possible answers, you can print any of them. It is possible to show, that there is at least one answer in the constraints of this problem.

Examples

Input


39


Output


4
5 3 

Input


1


Output


0


Input


7


Output


0

Note

In the first test, one of the transforms might be as follows: 39 → 56 → 57 → 62 → 63. Or more precisely:

  1. Pick n = 5. x is transformed into 39 ⊕ 31, or 56. 
  2. Increase x by 1, changing its value to 57. 
  3. Pick n = 3. x is transformed into 57 ⊕ 7, or 62. 
  4. Increase x by 1, changing its value to 63 = 2^6 - 1. 



In the second and third test, the number already satisfies the goal requirement.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.security.KeyPair;
import java.util.*;

public class Main {

    static long[][] c ;
    static long[] arr;
    static long n , m , k;
    static long dp[][][];
    static int[] parent; /// DSU

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        long n = Reader.nextLong();
        HashMap<Long,Boolean> map = new HashMap<>();
        long num = 2;
        long[] arr = new long[100];
        for (int i = 1; i < 100 ; i++){
            arr[i] = num;
            map.put(num-1,true);
            num*=2;
        }
        LinkedList<Long> ans = new LinkedList<>();
        int cnt = 0;
        while (!map.containsKey(n)){
            if (map.containsKey(n-1)){
                cnt++;
                ans.addLast((long)(Math.log(n)/Math.log(2)));
                break;
            }
            //System.out.println(Long.toBinaryString(n));
            //System.out.println(arr[((int)(Math.log(n)/Math.log(2))) + 1]-1);
            ans.addLast(((long)(Math.log(n)/Math.log(2))) + 1);
            n^=(arr[((int)(Math.log(n)/Math.log(2))) + 1]-1);
            //System.out.println(n);
            /*if (true){
                break;
            }*/
            cnt++;
            //System.out.println(n);
            if (map.containsKey(n)){
                //System.out.println("BREAK");
                break;
            }
            else{
                cnt++;
                n++;
            }
        }
        //System.out.println();
        System.out.println(cnt);
        while (!ans.isEmpty()){
            System.out.print(ans.removeFirst() + " ");
        }
        System.out.println();


        //System.out.println((((39^63)+1)^31)+1);

















    }




    static int find(int a){
        if (parent[a]!=a){
            parent[a] = find(parent[a]);
        }
        return parent[a];
    }



    public static void sortbyColumn_asc(int arr[][], int col)
    {
        // Using built-in sort function Arrays.sort
        Arrays.sort(arr, new Comparator<int[]>() {

            @Override
            // Compare values according to columns
            public int compare(final int[] entry1,
                               final int[] entry2) {

                // To sort in descending order revert
                // the '>' Operator
                if (entry1[col] > entry2[col])
                    return 1;
                else
                    return -1;
            }
        });  // End of function call sort().
    }

    public static void sortbyColumn_dsc(int arr[][], int col)
    {
        // Using built-in sort function Arrays.sort
        Arrays.sort(arr, new Comparator<int[]>() {

            @Override
            // Compare values according to columns
            public int compare(final int[] entry1,
                               final int[] entry2) {

                // To sort in descending order revert
                // the '>' Operator
                if (entry1[col] > entry2[col])
                    return -1;
                else
                    return 1;
            }
        });  // End of function call sort().
    }

    static void swap(char[] arr , int i , int j){
        char tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

    static void swap(int[] arr , int i , int j){
        int tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }





}

class Node implements Comparable<Node>{
    int a ;
    int b;
    Node(int a , int b){
        this.a = a;
        this.b = b;
    }
    public int compareTo(Node o) {
        return -1*(this.a - o.a);
    }
}
class Edge implements Comparable<Edge>{
    int x , y , w;

    public Edge(int x, int y, int w) {
        this.x = x;
        this.y = y;
        this.w = w;
    }

    @Override
    public int compareTo(Edge o) {
        return this.w - o.w;
    }
}
class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}
class MergeSort
{
    // Merges two subarrays of arr[].
    // First subarray is arr[l..m]
    // Second subarray is arr[m+1..r]
    void merge(int arr[], int l, int m, int r)
    {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int [n1];
        int R[] = new int [n2];

        /*Copy data to temp arrays*/
        for (int i=0; i<n1; ++i)
            L[i] = arr[l + i];
        for (int j=0; j<n2; ++j)
            R[j] = arr[m + 1+ j];


        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2)
        {
            if (L[i] <= R[j])
            {
                arr[k] = L[i];
                i++;
            }
            else
            {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1)
        {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2)
        {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    void sort(int arr[], int l, int r)
    {
        if (l < r)
        {
            // Find the middle point
            int m = (l+r)/2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr , m+1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    /* A utility function to print array of size n */
    static void printArray(int arr[])
    {
        int n = arr.length;
        for (int i=0; i<n; ++i)
            System.out.print(arr[i] + " ");
        System.out.println();
    }

    // Driver method

}