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

public class P223A {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(in, out);
		out.close();
	}

	static class Task {
		public void solve(InputReader in, PrintWriter out) {
			String s = in.nextLine();
			Stack<Integer> stack = new Stack<>();
			boolean[] valid = new boolean[s.length()];
			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				if (c == '(' || c == '[') {
					stack.push(i);
				} else if (c == ')' || c == ']') {
					if (!stack.empty() && ((c == ')' && s.charAt(stack.peek()) == '(')
							|| (c == ']' && s.charAt(stack.peek()) == '['))) {
						valid[stack.peek()] = true;
						valid[i] = true;
						stack.pop();
					} else {
						stack.clear();
					}
				}
			}
			int max = 0;
			int curr = 0;
			int start = -1, end = -1;
			int maxstart = -1, maxend = -1;
			for (int i = 0; i <= s.length(); i++) {
				if (i < s.length() && valid[i]) {
					if (s.charAt(i) == '[') {
						curr++;
					}
					if (start == -1)
						start = i;
					end = i;
				} else {
					if (curr > max) {
						max = curr;
						maxstart = start;
						maxend = end;
					}
					curr = 0;
					start = -1;
					end = -1;
				}
			}
			if (maxstart != -1 && maxend != -1) {
				out.println(max);
				for (int i = maxstart; i <= maxend; i++) {
					out.print(s.charAt(i));
				}
				out.println();
			} else {
				out.println(0);
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

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

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}

	}

}
