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.util.*;

public class Codeforces {
	FastScanner in;
	PrintWriter out;

	void solve() {
		char[] c = in.next().toCharArray();
		int n = c.length;
		char[] st = new char[n];
		int[] ind = new int[n];
		int[] cntgood = new int[n];
		if (c[0] == '[') {
			cntgood[0] = 1;
		}
		for (int i = 1; i < n; i++) {
			cntgood[i] = cntgood[i - 1];
			if (c[i] == '[') cntgood[i]++;
		}
		int sp = 0;
		int start = 0;
		int ans = 0;
		int cur = 0;
		int len = 0;
		int ansst = 0;
		for (int i = 0;  i < n; i++) {
			if (c[i] == ')' || c[i] == ']') {
				if (sp == 0 || (c[i] == ']' && st[sp - 1] == '(' || c[i] == ')' && st[sp - 1] == '[')) {
					sp = 0;
					start = i + 1;
					cur = 0;
				} else {
					sp--;
					int good = cntgood[i];
					if (sp != 0) {
						int lastbad = ind[sp - 1];
						good -= cntgood[lastbad];
					} else if (start != 0) {
						good -= cntgood[start - 1];
					}
					if (good > ans) {
						ans = good;
						if (sp == 0) ansst = start;
						else ansst = ind[sp - 1] + 1;
						len = i - ansst + 1;
					}
				}
			} else {
				if (c[i] == '[') {
					cur++;
				}
				ind[sp] = i;
				st[sp++] = c[i];
			}
		}
		out.println(ans);
		for (int i = ansst; i < ansst + len; i++) {
			out.print(c[i]);
		}
	}

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));

		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {

				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

	public static void main(String[] args) {
		new Codeforces().run();
	}
}