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.*;
import java.util.*;
import java.math.*;
@SuppressWarnings("unchecked")
public class DhakaJi {

    InputStream is;
    PrintWriter out;
    
    long mod = (long)(1e9 + 7), inf = (long)(3e18);
    boolean ok(int x){
        int m = log2(x);
        if((1<<(m+1))-1==x)
            return true ;
        return false ;
    }
    void solve() {
        //SZ = sieve(); //SZ = 1000001;
        int x = ni();
        StringBuilder sb = new StringBuilder("");
        int m = log2(x);
        if(((1<<(m+1))-1)==x)
        {
            out.println("0");
            return ;
        }        
        int count = 0 ;
        while(true){
            m = log2(x);
            int a = (1<<(m+1))-1;    
            sb.append((m+1)+" ");
            count++;
            x = x^a ;
            if(ok(x)){
                break ;
            }
            x++;
            count++;
            if(ok(x)){
                break ;
            
            }
        }
        out.println(count);
        out.println(sb);
        //out.println(sb);
        // int ans = Integer.parseInt(sb.toString(),2);
        // out.println("1");
        // out.println(ans);
    }
    
    //--------- Extra Template -----------
    boolean isPrime(long n) {
        if(n <= 1)  return false;
        if(n <= 3)   return true;
        if(n%2 == 0 || n%3 == 0)    return false;
        for(long i = 5; i * i <= n; i += 6) {
            if(n % i == 0 || n % (i + 2) == 0)  return false;
        }
        return true;
    }


    public int log2(int n){
        if(n <= 0) throw new IllegalArgumentException();
        return 31 - Integer.numberOfLeadingZeros(n);
    }
    int P[], S[], SZ, NP = 15485900;
    boolean isP[];    

    int sieve() {
        int i, j, n = NP; 
        isP = new boolean[n]; 
        S = new int[n];
        for(i = 3; i < n; i += 2) {
            isP[i] = true;
            S[i-1] = 2;
            S[i] = i;
        }
        isP[2] = true;
        S[1] = 1;   //(UD)
        for(i = 3; i * i <= n; i += 2) {
            if( !isP[i] )   continue;
            for(j = i * i; j < n; j += i) {
                isP[j] = false;
                if(S[j] == j)   S[j] = i;
            }
        }
        P = new int[n];
        P[0] = 2;
        j = 1;
        for(i = 3; i < n; i += 2) {
            if ( isP[i] )   P[j++] = i;
        }
        P = Arrays.copyOf(P, j);
        return j;
    }
    long gcd(long a,long b){
        while (a!=0 && b!=0) 
        {            
            if(a>b)
               a%=b;
            else
                b%=a;
        }
        return a+b;
    }
    long mp(long b, long e, long mod) {
        b %= mod;
        long r = 1;
        while(e > 0) {
            if((e & 1) == 1) {
                r *= b; r %= mod;
            }
            b *= b; b %= mod;
            e >>= 1;
        }
        return r;
    }

    //---------- I/O Template ----------
    
    public static void main(String[] args) throws Exception { new DhakaJi().run(); }
    void run() throws Exception { 
        is = System.in; 
        out = new PrintWriter(System.out);
        // long s = System.currentTimeMillis();
        solve();
        out.flush();
        // tr((System.currentTimeMillis()-s)/1000+"s");
    }
    
    byte input[] = new byte[1024];
    int len = 0, ptr = 0;
    
    int readByte() { 
        if(ptr >= len) { ptr = 0; 
            try { len = is.read(input); } 
            catch(IOException e) { throw new InputMismatchException(); } 
            if(len <= 0) { return -1; } 
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() { 
        int b = readByte(); 
        while(b != -1 && isSpaceChar(b)) { b = readByte(); } 
        return b;
    }
    
    char nc() { return (char)skip(); }
    String ns() { 
        int b = skip(); 
        StringBuilder sb = new StringBuilder(); 
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } 
        return sb.toString();
    }
    String nLine() { 
        int b = skip(); 
        StringBuilder sb = new StringBuilder(); 
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); } 
        return sb.toString();
    }
    int ni() { 
        int n = 0, b = readByte(); 
        boolean minus = false; 
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); } 
        if(b == '-') { minus = true; b = readByte(); } 
        if(b == -1) { return -1; }  //no input 
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); } 
        return minus ? -n : n;
    }
    long nl() { 
        long n = 0L;    int b = readByte(); 
        boolean minus = false; 
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); } 
        if(b == '-') { minus = true; b = readByte(); } 
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); } 
        return minus ? -n : n;
    }
    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) { 
        int a[] = new int[n]; 
        for(int i = 0; i < n; i++) { a[i] = ni(); } 
        return a;
    }
    char[] ns(int n) { 
        char c[] = new char[n]; 
        int i, b = skip(); 
        for(i = 0; i < n; i++) { 
            if(isSpaceChar(b)) { break; } 
            c[i] = (char)b; b = readByte(); 
        } return i == n ? c : Arrays.copyOf(c,i);
    }
    // private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
    // private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}