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 A {
	public void solve() throws IOException {
		String s = nextToken();
		int n = s.length();
		int[] pos = new int[n + 1];
		int[] type = new int[n + 1];
		int[] next = new int[n + 1];
		for (int i = 0; i < n; i++) next[i] = -1;
		int last = 0;
		for (int i = 0; i < n; i++)
			if (s.charAt(i) == '(' || s.charAt(i) == '[') {
				int kind = -1;
				if (s.charAt(i) == '(') kind = 1;
				pos[last] = i;
				type[last] = kind;
				last++;
			}
			else {
				int kind = -1;
				if (s.charAt(i) == ')') kind = 1;
				if (last > 0 && kind == type[last - 1]) 
					next[pos[--last]] = i;
				else 
					last = 0;
			}
		int[] cnt = new int[n + 1];
		for (int i = 0; i < n; i++) {
			cnt[i + 1] = cnt[i];
			if (s.charAt(i) == '[') cnt[i + 1]++;
		}
		//for (int i = 0; i < n; i++) writer.print(cnt[i] + " "); writer.println();
		int len = 0;
		int begin = -1;
		int end = -1;
		for (int i = 0; i < n; i++)
			if (next[i] != -1) {
				int j = next[i];
				while (j + 1 < n && next[j + 1] != -1) j = next[j + 1];
				//writer.println(j);
				if (cnt[j + 1] - cnt[i] >= len) {
					len = cnt[j + 1] - cnt[i];
					begin = i;
					end = j;
				}
				i = j;
			}
		writer.println(len);
		if (begin != -1 && end != -1) {
			for (int i = begin; i <= end; i++) writer.print(s.charAt(i));
			writer.println();
		}
	}

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

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			long tbegin = System.currentTimeMillis();
			reader = new BufferedReader(new InputStreamReader(System.in));
			//reader = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt")));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			//writer = new PrintWriter(new FileOutputStream("output.txt"));
			solve();
			//reader.close();
			//System.out.println(System.currentTimeMillis() - tbegin + "ms");
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

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

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

}
