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.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Stack;
import java.util.StringTokenizer;

public class A {

    static StringTokenizer st;
    static BufferedReader in;
    static class Sort implements Comparable<Sort> {
        int x, y, cnt;
        public int compareTo(Sort o) {
            return this.x-o.x;
        }
        public Sort (int x, int y, int cnt) {
            this.x = x;
            this.y = y;
            this.cnt = cnt;
        }
    }
    
    public static void main(String[] args) throws IOException{
        in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        String s = next();
        Stack<Character> st_char = new Stack<Character>();
        Stack<Integer> st_ind = new Stack<Integer>();
        int[]cnt = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i)=='[')
                cnt[i] = 1;
            if (i > 0)
                cnt[i] += cnt[i-1];
        }
        ArrayList<Sort> ends = new ArrayList<Sort>();
        for (int i = 0; i < s.length(); i++) {
            char w = s.charAt(i);
            if (w=='(' || w=='[') {
                st_char.push(w);
                st_ind.push(i);
            }
            else if (!st_char.isEmpty() && st_char.peek()==opposite(w)){
                int t = cnt[i];
                if (st_ind.peek() > 0)
                    t -= cnt[st_ind.peek()-1];
                ends.add(new Sort(st_ind.peek(), i, t));
                st_char.pop();
                st_ind.pop();
            }
            else {
                st_char.clear();
                st_ind.clear();
            }
        }
        Collections.sort(ends);
        int last = 0;
        int[]L = new int[ends.size()], R = new int[ends.size()];
        if (ends.isEmpty()) {
            System.out.println(0);
            return;
        }
        L[0] = ends.get(0).x;
        R[0] = ends.get(0).y;
        int[]num = new int[ends.size()];
        num[0] = ends.get(0).cnt;
        int max_right = ends.get(0).y;
        int q_last = ends.get(0).y;
        for (int i = 1; i < ends.size(); i++) {
            if (ends.get(i).x==q_last+1) {
                R[last] = ends.get(i).y;
                num[last] += ends.get(i).cnt;
                q_last = ends.get(i).y;
            }
            else if (ends.get(i).y > max_right){
                last = i;
                q_last = ends.get(i).y;
                num[i] = ends.get(i).cnt;
                L[i] = ends.get(i).x;
                R[i] = ends.get(i).y;
            }
            max_right = Math.max(max_right, ends.get(i).y);
        }
        int max = -1, left = 0, right = 0;
        for (int i = 0; i < num.length; i++) {
            if (num[i] > max) {
                max = num[i];
                left = L[i];
                right = R[i];
            }
        }
        if (max==-1)
            pw.println(0);
        else {
            pw.println(max);
            pw.println(s.substring(left, right+1));
        }
        pw.close();
    }

    private static char opposite(char w) {
        if (w==']')
            return '[';
        return '(';
    }

    private static int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    
    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
}

