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.util.concurrent.ArrayBlockingQueue;

public class Lrn1 {

    static List<chpos> poss = new ArrayList<chpos>();

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        Stack<lbpos> chps = new Stack<lbpos>();

        for (int i = 0; i < s.length(); i++) {

            if (s.charAt(i) == '[' || s.charAt(i) == '(')
                chps.push(new lbpos(i, s.charAt(i)));
            else {
                if (!chps.isEmpty()) {
                    if (s.charAt(i) == ']') {
                        lbpos c = chps.peek();
                        if (c.r != '[') {
                            chps.clear();
                        } else {
                            lbpos d = chps.pop();
                            add(d.l, i);
                        }
                    } else {
                        lbpos c = chps.peek();
                        if (c.r != '(') {
                            chps.clear();
                        } else {
                            lbpos d = chps.pop();
                            add(d.l, i);
                        }

                    }

                }
            }

        }
        
        Collections.sort(poss);

    //  System.out.println(poss);

        List<chpos> refined = new ArrayList<chpos>();
        chpos cur = null;
        for (int j = 0; j < poss.size(); j++) {
            if (cur != null) {
                if (poss.get(j).l < cur.r) {
                    continue;
                }
                if (cur.r + 1 == poss.get(j).l)
                    cur.r = poss.get(j).r;
                else {
                    refined.add(cur);
                    cur = poss.get(j);
                }
            } else
                cur = poss.get(j);
        }
        
    //  System.out.println(refined);

        if (cur != null)
            refined.add(cur);

        int ansl = -1;
        int ansr = -1;
        int maxc = 0;

        for (chpos temp : refined) {

            int count = 0;
            for (int h = temp.l; h <= temp.r; h++) {
                if (s.charAt(h) == '[')
                    count++;
            }

            if (count > maxc) {
                maxc = count;
                ansl = temp.l;
                ansr = temp.r;

            }
        }

        if (ansl == -1 || ansr == -1)
            System.out.println(0);
        else {
            System.out.println(maxc);
            for (int k = ansl; k <= ansr; k++) {
                System.out.print(s.charAt(k));
            }
        }

    }

    public static void add(int l, int r) {
        if (l != -1 && r != -1) {
            poss.add(new chpos(l, r));
        }
    }

    static class chpos implements Comparable<chpos> {

        int l;
        int r;

        public chpos(int a, int b) {
            this.l = a;
            this.r = b;
        }

        public String toString() {
            return (this.l + " " + this.r);
        }

        @Override
        public int compareTo(chpos o) {
            return (this.l - o.l);
        }
    }

    static class lbpos {

        int l;
        char r;

        public lbpos(int a, char b) {
            this.l = a;
            this.r = b;
        }

        public String toString() {
            return (this.l + " " + this.r);
        }
    }

}
