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.*;
import java.math.*;

public class A implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	static class OpenBracket {

		int type, pos;

		public OpenBracket(char c, int i) {
			if (c == '(')
				type = 0;
			else if (c == '[')
				type = 1;
			else
				throw new AssertionError();

			pos = i;
		}

		public static boolean isOpenBracket(char c) {
			return (c == '(' || c == '[');
		}

		public static boolean isGood(int type, char c) {
			if (type == 0 && c == ')')
				return true;

			if (type == 1 && c == ']')
				return true;

			return false;
		}

	}

	void solve() throws IOException {
		String s = nextToken();
		Stack<OpenBracket> openBrackets = new Stack<A.OpenBracket>();

		boolean[] badPoses = new boolean[s.length()];
		int[] openPos = new int[s.length()], closePos = new int[s.length()];

		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);

			if (OpenBracket.isOpenBracket(c)) {
				openBrackets.add(new OpenBracket(c, i));
			} else {
				if (openBrackets.size() == 0) {
					badPoses[i] = true;
				} else {
					OpenBracket polled = openBrackets.pop();

					if (!OpenBracket.isGood(polled.type, c)) {
						badPoses[i] = true;
						badPoses[polled.pos] = true;
					} else {
						openPos[i] = polled.pos;
						closePos[polled.pos] = i;
					}
				}
			}
		}

		while (openBrackets.size() > 0) {
			badPoses[openBrackets.pop().pos] = true;
		}

		int[] badPosesSum = new int[s.length()], niceBracketsSum = new int[s
				.length()];

		for (int i = 0; i < s.length(); i++) {
			{
				int add = badPoses[i] ? 1 : 0, prev = (i == 0) ? 0
						: badPosesSum[i - 1];
				badPosesSum[i] = add + prev;
			}

			{
				int add = s.charAt(i) == '[' ? 1 : 0, prev = (i == 0) ? 0
						: niceBracketsSum[i - 1];
				niceBracketsSum[i] = add + prev;
			}

		}

		for (int i = 0; i < s.length() - 1; i++) {
			char cur = s.charAt(i), next = s.charAt(i + 1);

			if (!OpenBracket.isOpenBracket(cur)
					&& OpenBracket.isOpenBracket(next) && !badPoses[i]
					&& !badPoses[i + 1]) {

				int leftLeftBorder = openPos[i], leftRightBorder = i;
				int rightLeftBorder = i + 1, rightRightBorder = closePos[i + 1];

				if (getSum(badPosesSum, leftLeftBorder, leftRightBorder) == 0
						&& getSum(badPosesSum, rightLeftBorder,
								rightRightBorder) == 0) {
					closePos[leftLeftBorder] = rightRightBorder;
					openPos[rightRightBorder] = leftLeftBorder;
				}
			}
		}

		int resCount = 0, leftBorder = 0, rightBorder = -1;

		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			int curClosePos = closePos[i];

			if (OpenBracket.isOpenBracket(c) && curClosePos > i
					&& getSum(badPosesSum, i, curClosePos) == 0) {

				int curNiceBrackets = getSum(niceBracketsSum, i, curClosePos);

				if (curNiceBrackets > resCount) {
					resCount = curNiceBrackets;
					leftBorder = i;
					rightBorder = curClosePos;
				}
			}
		}

		out.println(resCount);
		out.println(s.substring(leftBorder, rightBorder + 1));
	}

	private int getSum(int[] sum, int l, int r) {
		if (l > r)
			return 0;

		return sum[r] - ((l == 0) ? 0 : sum[l - 1]);
	}

	public static void main(String[] args) {
		// final boolean oldChecker = false;
		//
		// if (oldChecker)
		// new Thread(null, new Template(), "yarrr", 1 << 24).start();
		// else
		new A().run();
	}

	public void run() {
		try {
			// final String className = this.getClass().getName().toLowerCase();
			//
			// try {
			// in = new BufferedReader(new FileReader(className + ".in"));
			// out = new PrintWriter(new FileWriter(className + ".out"));
			// } catch (FileNotFoundException e) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			// }

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

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

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

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