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.io.*;

public class Main implements Runnable {
		
	public void solve() throws IOException {
		char[] c = nextToken().toCharArray();
                
                int answer = 0;
                int[] pair = new int[c.length];
                Arrays.fill(pair, -1);
                Stack<Integer> stk = new Stack<>();
                for(int i = 0; i < c.length; i++){
                    if(c[i] == '(' || c[i] == '[') stk.push(i);
                    else{
                        char needed = (c[i] == ')') ? '(' : '[';
                        if(stk.isEmpty() || c[stk.peek()] != needed) stk = new Stack<>();
                        else{
                            int past = stk.pop();
                            pair[i] = past;
                            pair[past] = i;
                        }
                    }
                }
                
                int left = -1, right = -1;
                for(int i = 0; i < c.length;){
                    if(pair[i] >= i){
                        int tempLeft = i;
                        int countBrackets = 0;
                        while(i < c.length && pair[i] >= i){
                            for(int k = i; k <= pair[i]; k++){
                                if(c[k] == '[') countBrackets++;
                            }
                            i = pair[i] + 1;
                        }
                        if(countBrackets > answer){
                            answer = countBrackets;
                            left = tempLeft;
                            right = i;
                        }
                    }
                    else{
                        i++;
                    }
                }
                
                System.out.println(answer);
                StringBuilder sb = new StringBuilder();
                for(int i = left; i < right; i++) sb.append(c[i]);
                System.out.println(sb.toString());
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	//-----------------------------------------------------------
	public static void main(String[] args) {
		new Main().run();
	}

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }
        
        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }
        
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tok = null;
			solve();
			in.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

	public String nextToken() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	BufferedReader in;
	StringTokenizer tok;
}