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.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class P_223A {
    static final FS sc = new FS();
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        char[] s = sc.next().toCharArray();
        int[] arr = new int[s.length+1];
        Stack<Integer> st = new Stack<>();
        for(int i=0; i<s.length; i++){
            if(s[i]=='('||s[i]=='['){
                st.push(i);
            }
            else{
                if(!st.isEmpty()){
                    int top = st.peek();
                    if(s[top]=='('&&s[i]==')' || s[top]=='['&&s[i]==']'){
                        arr[top] = 1;
                        arr[i] = 1;
                        st.pop();
                    }
                    else{
                        while(!st.isEmpty()) st.pop();
                    }
                }
            }
        }
        int i, x = -1, currSq = 0, xi = 0, yi = 0, start = 0, maxSq = 0;
        for(i=0; i<s.length; i++){
            if(arr[i]==0){
                if(maxSq<currSq){
                    maxSq = currSq;
                    xi = x;
                    yi = i;
                }
                start = 0;
                currSq = 0;
            }
            else{
                if(start==0) x = i;
                if(s[i]=='[') currSq++;
                start++;
            }
        }
        if(maxSq<currSq){
            maxSq = currSq;
            xi = x;
            yi = i;
        }
        StringBuilder sb = new StringBuilder();
        sb.append(maxSq).append("\n");
        for(int j=xi; j<yi; j++) sb.append(s[j]);
        System.out.println(sb.toString());
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception ignored) {
                }
            }
            return st.nextToken();
        }

        int[] nextArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
