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.util.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class  test{
	
	// ArrayList<Integer> lis = new ArrayList<Integer>();
	// ArrayList<String> lis = new ArrayList<String>();
	// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
	//  Stack<Integer> que = new Stack<Integer>();
    //	static long sum=0;
	// int a,b,c;
	// 1000000007 (10^9+7)
	//static int mod = 1000000007;
    //static int dx[]={1,-1,0,0};
	//static int dy[]={0,0,1,-1};
    //static long H,L;
	
public  static void main(String[] args)   throws Exception, IOException{
   //String line=""; throws Exception, IOException
   //(line=br.readLine())!=null
	//Scanner sc =new Scanner(System.in);
	Reader sc = new Reader(System.in);
  // while( ){
	 //  int  n=sc.nextInt(),m=sc.nextInt(),a[]=new int[n];
	
	String s=sc.nextString(),re="";
	int l=s.length(),ans=0;
	  Stack<Integer> que = new Stack<Integer>();
	boolean b[]=new boolean[l];
	for(int i=0; i<l ;i++){
	char  c=s.charAt(i);
	   if( c==')' || c==']' ){
		  
		   if(que.isEmpty())continue;
		   int k=que.peek();
		  if( s.charAt(k)=='(' && c==')' ){ b[k]=b[i]=true; que.pop(); } 
		  else  if( s.charAt(k)=='[' && c==']' ){ b[k]=b[i]=true; que.pop(); }   
		  else que.clear();
	   }
	   else que.add(i);
	}
	
	for(int i=0; i<l ;i++){
		int c=0,st=i,en=0;
		if(b[i] ){
			while( i<l && b[i] ){if(s.charAt(i)=='[')c++; en=i; i++;}
			if( ans<c ){ ans=c; re=s.substring(st,en+1); }
			
		}
	  	
	}
	
	System.out.println(ans);
	System.out.println(re);
	
}

static void db(Object... os){
    System.err.println(Arrays.deepToString(os));

}

}


/*
class P implements Comparable<P>{
//	implements Comparable<P>
    
	int x;
	boolean b;
	P(int x,boolean b){
		this.x=x;
		this.b=b;
	} 

	   public int compareTo(P y){
         
		  return  x-y.x;
		   
		   }	
	
}
//*/
class Reader
{
	private BufferedReader x;
	private StringTokenizer st;
	
	public Reader(InputStream in)
	{
		x = new BufferedReader(new InputStreamReader(in));
		st = null;
	}
	public String nextString() throws IOException
	{
		while( st==null || !st.hasMoreTokens() )
			st = new StringTokenizer(x.readLine());
		return st.nextToken();
	}
	public int nextInt() throws IOException
	{
		return Integer.parseInt(nextString());
	}
	public long nextLong() throws IOException
	{
		return Long.parseLong(nextString());
	}
	public double nextDouble() throws IOException
	{
		return Double.parseDouble(nextString());
	}
}
