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.*;
import java.math.BigInteger;
import java.util.*;



public class A {
    public void run() throws IOException {
        char[] cs = IOFast.next().toCharArray();
        int n = cs.length;
        int[] prev = new int[n];
        int[] count = new int[n+1];
        
        for(int i = 0; i < n; i++) {
            if(cs[i] == '[') {
                count[i+1]++;
            }
            count[i+1] += count[i];
        }
        
        boolean[][] match = new boolean[256][256];
        match['('][')'] = true;
        match['['][']'] = true;
        prev[0] = -1;
        for(int i = 1; i < n; i++) {
            char a = cs[i-1], b = cs[i];
            prev[i] = -1;
            if("([".indexOf(a) != -1) {
                if(match[a][b]) {
                    prev[i] = i == 1 || prev[i-2] == -1 ? i - 1 : prev[i-2];
                }
            }
            else if("([".indexOf(b) == -1) {
                int p = prev[i-1];
                if(p > 0 && match[cs[p - 1]][b]) {
                    prev[i] = p - 2 > 0 && prev[p - 2] != -1 ? prev[p - 2] : p - 1;
                }
            }
        }
        
//      System.err.println(Arrays.toString(prev));
        int l = 0, r = 0, max = 0;
        for(int i = 0; i < n; i++) {
            if(prev[i] != -1) {
                int x = count[i+1] - count[prev[i]];
                if(max < x) {
                    l = prev[i];
                    r = i + 1;
                    max = x;
                }
            }
        }

        IOFast.out.println(max);
        IOFast.out.println(new String(cs).substring(l, r));
    }
    
    public static void main(String[] args) throws IOException {
        new A().run();
        IOFast.out.flush();
    }

    static public class IOFast {
        private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        private static PrintWriter out = new PrintWriter(System.out);

//      private static final int BUFFER_SIZE = 50 * 200000;
        private static int pos, readLen;
        private static final char[] buffer = new char[1024 * 8];
        private static final StringBuilder buf = new StringBuilder();
        private static boolean[] isDigit = new boolean[256];
        private static boolean[] isSpace = new boolean[256];

        static {
            for(int i = 0; i < 10; i++) {
                isDigit['0' + i] = true;
            }
            isDigit['-'] = true;
            isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
        }
        
        static boolean endInput;
        
        private static int read() throws IOException {
            if(readLen == -1) {
                return -1;
            }
            
            if(pos >= readLen) {
                readLen = in.read(buffer);
                pos = 0;
                
                if(readLen <= 0) {
                    return -1;
                }
            }
            
            return buffer[pos++];
        }

        private static int nextInt() throws IOException {
            boolean plus = false;
            int ret = 0;
            while(true) {
                final int c = read();
                
                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }
                
                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }
            
            while(true) {
                final int c = read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }
            
            return plus ? ret : -ret;
        }
        
        private static long nextLong() throws IOException {
            boolean plus = false;
            long ret = 0;
            while(true) {
                final int c = read();
                
                if(c == -1) {
                    endInput = true;
                    return Integer.MIN_VALUE;
                }
                
                if(isDigit[c]) {
                    if(c != '-') {
                        plus = true;
                        ret = c - '0';
                    }
                    break;
                }
            }
            
            while(true) {
                final int c = read();
                if(c == -1 || !isDigit[c]) {
                    break;
                }
                ret = ret * 10 + c - '0';
            }
            
            return plus ? ret : -ret;
        }

        private static char nextChar() throws IOException {
            while(true) {
                final int c = read();
                
                if(c == -1) {
                    endInput = true;
                    return '\0';
                }
                
                if(!isSpace[c]) {
                    return (char)c;
                }
            }
        }

        private static int next(char[] cs) throws IOException {
            int n = 0;
            while(true) {
                final int c = read();
                
                if(c == -1) {
                    endInput = true;
                    return n;
                }
                
                if(!isSpace[c]) {
                    cs[n++] = (char)c;
                    break;
                }
            }
            
            while(true) {
                final int c = read();
                
                if(c == -1 || isSpace[c]) {
                    break;
                }
                cs[n++] = (char)c;
            }
            
            return n;
        }

        private static String next() throws IOException {
            buf.setLength(0);

            while(true) {
                final int c = read();
                
                if(c == -1) {
                    endInput = true;
                    return "-1";
                }
                
                if(!isSpace[c]) {
                    buf.append((char)c);
                    break;
                }
            }
            
            while(true) {
                final int c = read();
                
                if(c == -1 || isSpace[c]) {
                    break;
                }
                buf.append((char)c);
            }

            return buf.toString();
        }

        private static double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

    }

}
