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.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution implements Runnable {

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws Exception {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}

	void solve() throws Exception {
		String s = nextToken();
		int n = s.length();
		int[] stack = new int[n];
		int[] stp = new int[n];
		int l = 0;
		int[] st2b = new int[n];
		int[] st2e = new int[n];
		int l2 = 0;
		for (int i = 0; i < n; i++) {
			char c = s.charAt(i);
			if (c == '(') {
				stack[l] = 0;
				stp[l++] = i;
			}
			if (c == '[') {
				stack[l] = 1;
				stp[l++] = i;
			}
			if (c == ')') {
				if (l > 0 && stack[l - 1] == 0) {
					while (l2 > 0 && st2b[l2 - 1] >= stp[l - 1]) l2--;
					l2++;
					st2b[l2 - 1] = stp[l - 1];
					st2e[l2 - 1] = i;
					l--;
				} else {
					l = 0;
				}
			}
			if (c == ']') {
				if (l > 0 && stack[l - 1] == 1) {
					while (l2 > 0 && st2b[l2 - 1] >= stp[l - 1]) l2--;
					l2++;
					st2b[l2 - 1] = stp[l - 1];
					st2e[l2 - 1] = i;
					l--;
				} else {
					l = 0;
				}
			}
		}
		int[] cs = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			cs[i] = cs[i - 1];
			if (s.charAt(i - 1) == '[') cs[i]++;
		}
		int ans = -1;
		int anb = 0, ane = 0;
		for (int i = 0; i < l2;) {
			int j = i + 1;
			while (j < l2 && st2e[j - 1] == st2b[j] - 1) j++;
			if (ans == -1 || cs[st2e[j - 1] + 1] - cs[st2b[i]] > ans) {
				ans = cs[st2e[j - 1] + 1] - cs[st2b[i]];
				anb = st2b[i]; ane = st2e[j - 1];
			}
			i = j;
		}
		if (ans == -1) out.println(0); else {
			out.println(ans);
			out.println(s.substring(anb, ane + 1));
		}
	}

	public void run() {
		try {
			Locale.setDefault(Locale.UK);
			in = new BufferedReader(new InputStreamReader(System.in));
			// in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter(System.out);
			// out = new PrintWriter("output.txt");
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) {
		// new Thread(null, new Solution(), "1", 1 << 28).start();
		(new Solution()).run();
	}

}