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.io.*;
import static java.lang.Math.*;

public class PracticeProblem
{
    /*
     * This FastReader code is taken from GeeksForGeeks.com
     * https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
     *
     * The article was written by Rishabh Mahrsee
     */
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static FastReader in = new FastReader();
    public static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args)
    {
        solve();
        out.close();
    }

    private static void solve()
    {
        char[] arr = ("|" + in.nextLine() + "|").toCharArray(); // The beginning and end are just dummy characters
        int n = arr.length;
        int[] numOpen = new int[n];

        Stack<Integer> st = new Stack<>();

        int i = 0;

        while (i < n)
        {
            int size = st.size();
            if (st.size() > 1 && (arr[st.get(size - 2)] == '(' && arr[st.get(size - 1)] == ')' || arr[st.get(size - 2)] == '[' && arr[st.get(size - 1)] == ']'))
            {
                st.pop();
                st.pop();
            }
            else
            {
                numOpen[i] = i - 1 >= 0 ? numOpen[i - 1] : 0;
                st.push(i);
                if (arr[i] == '[')
                    numOpen[i]++;
                i++;
            }
        }

        int max = -1;
        int ansl = -1;
        int ansr = -1;

        for (int j = 1; j < st.size(); j++)
        {
            int openCount = numOpen[st.get(j) - 1] - numOpen[st.get(j - 1)];
            if (openCount > max)
            {
                max = openCount;
                ansl = st.get(j - 1) + 1;
                ansr = st.get(j);
            }
        }

        out.println(max);
        out.println(new String(arr).substring(ansl, ansr));
    }
}