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.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

/**
 * 111118315581
 *
 * -3 3 2 3 2 3 2 3 -3 3 -3 3 -3 3 2 3
 *
 * @author pttrung
 */
public class A {

    public static long x, y, gcd;
    public static int Mod = 1000000007;

    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        String val = in.next();
        Stack<Integer> s = new Stack();
        int[] pos = new int[val.length()];
        int[] point = new int[val.length()];
        Arrays.fill(pos, -1);

        for (int i = 0; i < val.length(); i++) {
            char c = val.charAt(i);
            if (c == '(' || c == '[') {

                s.push(i);

            } else {
                if (!s.isEmpty()) {
                    int index = s.peek();
                    if (val.charAt(index) == '(' && c == ')') {
                        s.pop();

                        pos[i] = index;
                        point[i] = (pos[i - 1] != -1 ? point[i - 1] : 0);
                        if (index > 0) {
                            if (pos[index - 1] != -1) {
                                pos[i] = pos[index - 1];
                                point[i] += point[index - 1];
                                point[index - 1] = point[i];
                            }
                        }
                    } else if (val.charAt(index) == '[' && c == ']') {
                        s.pop();
                        pos[i] = index;
                        point[i] = 1 + (pos[i - 1] != -1 ? point[i - 1] : 0);


                        if (index > 0) {
                            if (pos[index - 1] != -1) {
                                pos[i] = pos[index - 1];
                                point[i] += point[index - 1];
                                point[index - 1] = point[i];

                            }
                        }
                    } else {

                        s.clear();
                    }
                }
            }
        }
        int max = 0;
        int index = -1;
        for (int i = 0; i < val.length(); i++) {
            if (max <= point[i]) {
                max = point[i];
                index = i;
            }
        }
        out.println(max);
        if (max > 0) {
            out.println(val.substring(pos[index], index + 1));
        }
        out.close();
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }

    }

    public static String getSub(int length, String val) {
        String sub = val.substring(0, length);
        for (int i = length; i < val.length(); i += length) {
            String temp = val.substring(i, i + length);
            if (!temp.equals(sub)) {
                return null;
            }
        }
        return sub;
    }

    public static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static void extendEuclid(long a, long b) {
        if (b == 0) {
            x = 1;
            y = 0;
            gcd = a;
            return;
        }
        extendEuclid(b, a % b);
        long x1 = y;
        long y1 = x - (a / b) * y;
        x = x1;
        y = y1;

    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //      br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("basketball_game.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}
