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.InputStreamReader;
import java.io.IOException;
import java.math.BigDecimal;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author aircube
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastInputReader in = new FastInputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, FastInputReader in, PrintWriter out) {
        char[]s = in.nextString().toCharArray();
        int n = s.length;
        int[] st = new int[n];
        int ptr = 0;
        boolean pair[] = new boolean[n];
        for (int i = 0; i < n; ++i) {
            if (s[i] == '(' || s[i] == '[') {
                st[ptr ++] = i;
            } else {
                if (ptr >= 1 && ((s[st[ptr - 1]] == '(' && s[i] == ')') || (s[st[ptr - 1]] == '[' && s[i] == ']'))) {
                    pair[i] = pair[st[ptr - 1]] = true;
                    --ptr;
                } else {
                    ptr = 0;
                }
            }
        }
//        out.println(Arrays.toString(pair));
        int best = 0, l = 0, r = -1;
        for (int i = 0, j; i < n; i = j) {
            if (!pair[i]) {
                j = i + 1;
                continue;
            }
            for (j = i; j < n && pair[j]; ++j) ;
            int cnt = 0;
            for (int u = i; u < j; ++u) {
                cnt += s[u] == '[' ? 1 : 0;
            }
            if (best < cnt) {
                best = cnt;
                l = i;
                r = j - 1;
            }
        }
        out.println(best);
        out.print(new String(s).substring(l, r + 1));
	}
}

class FastInputReader {
    private StringTokenizer tokenizer;
    public BufferedReader reader;

    public FastInputReader(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
        tokenizer = null;
    }

    public String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException e) {
            return "-1";
        }
        return tokenizer.nextToken();
    }

    public String nextString() {
        return next();
    }

    }

