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.Arrays;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Stack;
import java.awt.*;
import static java.lang.Integer.*;
import static java.lang.Math.*;
@SuppressWarnings("unused")
public class round130A {

    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        char [] in = input.toCharArray();
        Stack<Integer> s = new Stack<Integer>();
        int [] correspond = new int [input.length()];
        Arrays.fill(correspond, -1);
        for(int i = 0 ; i < in.length ; ++i){
            if(in[i] == '(' || in[i] == '['){
                s.push(i);
            }else{
                if(in[i] == ')'){
                    if(s.empty())
                        continue;
                    if(in[s.peek()] == '('){
                        correspond[s.peek()] = i;
                        s.pop();
                    }
                    else
                        s.clear();
                }else{
                    if(in[i] == ']'){              
                        if(s.empty())
                            continue;
                        if(in[s.peek()] == '['){
                            correspond[s.peek()] = i;
                            s.pop();
                        }
                        else
                            s.clear();
                    }
                }
            }
        }
        int [] cum_sum = new int [in.length];
        cum_sum[0] = in[0] == '[' ? 1 : 0;
        for(int i = 1 ; i < in.length ; ++i)
            cum_sum[i] = cum_sum[i - 1] + (in[i] == '[' ? 1 : 0);
        int max = 0;
        int l = -2;
        int r = -2;
        int b_l = -10;
        int b_r = -10;
        int count = 0;
        for(int i = 0 ; i < in.length ; ){
            if(correspond[i] == -1){
                ++i;
                continue;
            }
            if(i == r + 1){
                count += cum_sum[correspond[i]] - (i == 0 ? 0 : cum_sum[i - 1]);
                r = correspond[i];
                i = r + 1;
            }
            else{
                if(count > max){
                    b_l = l;
                    b_r = r;
                    max = count;
                }
                count = 0;
                l = i;
                r = correspond[i];
                i = correspond[i] + 1;
                count += cum_sum[r] - (l == 0 ? 0 : cum_sum[l - 1]);
            }
        }
        if(count > max){
            b_l = l;
            b_r = r;
            max = count;
        }
        if(b_l < 0 && b_r < 0){
            System.out.println(0);
        }else{
            System.out.println(max);
            System.out.println(input.substring(b_l, b_r + 1));
        }
    }
}
