A bracket sequence is a string, containing only characters "(", ")", "[" and "]".

A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()[]", "([])" are correct (the resulting expressions are: "(1)+[1]", "([1+1]+1)"), and "](" and "[" are not. The empty string is a correct bracket sequence by definition.

A substring s[l... r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2... s|s| (where |s| is the length of string s) is the string slsl + 1... sr. The empty string is a substring of any string by definition.

You are given a bracket sequence, not necessarily correct. Find its substring which is a correct bracket sequence and contains as many opening square brackets «[» as possible.

Input

The first and the only line contains the bracket sequence as a string, consisting only of characters "(", ")", "[" and "]". It is guaranteed that the string is non-empty and its length doesn't exceed 105 characters.

Output

In the first line print a single integer — the number of brackets «[» in the required bracket sequence. In the second line print the optimal sequence. If there are more than one optimal solutions print any of them.

Examples

Input

([])


Output

1
([])


Input

(((


Output

0
import java.io.*;
import java.util.*;
public class Main implements Runnable{
    
    private void solve()throws IOException{
        char s[]=(" "+nextLine()).toCharArray();
        int n=s.length-1;
        int dp[]=new int[n+1];//length of longest rbs ending at i
        int dp2[]=new int[n+1];//number of [] in longest rbs ending at i
        for(int i=1;i<=n;i++){
            if(s[i]==']'){
                if(s[i-1]=='['){
                    dp[i]=2+dp[i-2];
                    dp2[i]=2+dp2[i-2];
                }
                else if(s[i-1]==']'){
                    if(s[i-1-dp[i-1]]=='['){
                        dp[i]=2+dp[i-1]+dp[i-1-dp[i-1]-1];
                        dp2[i]=2+dp2[i-1]+dp2[i-1-dp[i-1]-1];
                    }
                }
                else if(s[i-1]==')'){
                    if(s[i-1-dp[i-1]]=='['){
                        dp[i]=2+dp[i-1]+dp[i-1-dp[i-1]-1];
                        dp2[i]=2+dp2[i-1]+dp2[i-1-dp[i-1]-1];
                    }
                }
            }
            else if(s[i]==')'){
                if(s[i-1]=='('){
                    dp[i]=2+dp[i-2];
                    dp2[i]=dp2[i-2];
                }
                else if(s[i-1]==')'){
                    if(s[i-1-dp[i-1]]=='('){
                        dp[i]=2+dp[i-1]+dp[i-1-dp[i-1]-1];
                        dp2[i]=dp2[i-1]+dp2[i-1-dp[i-1]-1];
                    }
                }
                else if(s[i-1]==']'){
                    if(s[i-1-dp[i-1]]=='('){
                        dp[i]=2+dp[i-1]+dp[i-1-dp[i-1]-1];
                        dp2[i]=dp2[i-1]+dp2[i-1-dp[i-1]-1];
                    }
                }
            }
        }
        // for(int i=1;i<=n;i++){
        //     out.println(dp[i]+" "+dp2[i]);
        // }
        int maxi=0;
        for(int i=1;i<=n;i++){
            if(dp2[i]>dp2[maxi])
                maxi=i;
        }
        out.println(dp2[maxi]/2);
        for(int i=maxi-dp[maxi]+1;i<=maxi;i++)
            out.print(s[i]);
    }
    class Pair{
        int first,second;
        Pair(int a,int b){
            first=a;
            second=b;
        }
    }

     
    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}