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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Nafiur Rahman Khadem Shafin 🙂
 */
public class Main {
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader (inputStream);
		PrintWriter out = new PrintWriter (outputStream);
		TaskA solver = new TaskA ();
		solver.solve (1, in, out);
		out.close ();
	}
	
	static class TaskA {
		public void solve (int testNumber, InputReader in, PrintWriter out) {
			/*
			 * Dangerous problem 😞. If it would have been subsequence instead of substring 😜. Well, let's start from
			 * leftmost [ and
			 * then try to check till the rightmost ]. [[()]) eitar last e stack theke ber hobe ekta [. zekoyta stack theke
			 * ber hobe
			 * sheita factor. Not koyta dhuklo. invalid pawar por abar notun kore shuru. But the problem is lots of corner
			 * case, karon
			 * invalid paileo kotha theke koto tuku valid sheita bojha eto shohoj na. e.g. [[[]][]([[]](
			 */
			String orstr = in.next ();
			char[] str = orstr.toCharArray ();
			boolean[] flg = new boolean[str.length+5];
			Stack <TaskA.Pair> os = new Stack <> ();
			for (int i = 0; i<str.length; i++) {
				if ((str[i]==']' && (os.empty () || os.peek ().c!='[')) ||
							(str[i]==')' && (os.empty () || os.peek ().c!='('))) {
					os.clear ();
				}
				else if (str[i]==']' || str[i]==')') {
					flg[os.pop ().idx] = flg[i] = true;
				}
				else {
					os.push (new TaskA.Pair (str[i], i));
				}
			}
			int max = 0, start = -1, len = -1;
			for (int i = 0; i<str.length; ++i) {
				if (flg[i]) {
					int lst = i, cnt = 0;
					while (lst<str.length && flg[lst]) {
						if (str[lst++]=='[') {
							++cnt;
						}
					}
					if (cnt>max) {
						max = cnt;
						start = i;
						len = lst-start;
					}
					i = lst-1;
				}
			}
			out.println (max);
			if (max==0) {
				out.println ();
			}
			else {
				out.println (new String (str, start, len));
			}
		}
		
		private static class Pair {
			char c;
			int idx;
			
			public Pair (char c, int idx) {
				this.c = c;
				this.idx = idx;
			}
			
		}
		
	}
	
	static class InputReader implements AutoCloseable {
		private BufferedReader reader;
		private StringTokenizer tokenizer;
		
		public InputReader (InputStream stream) {
			reader = new BufferedReader (new InputStreamReader (stream));
			tokenizer = null;
		}
		
		public String next () {
			while (tokenizer==null || !tokenizer.hasMoreTokens ()) {
				try {
					String str;
					if ((str = reader.readLine ())!=null) tokenizer = new StringTokenizer (str);
					else return null;//to detect eof
				} catch (IOException e) {
					throw new RuntimeException (e);
				}
			}
			return tokenizer.nextToken ();
		}
		
		
		public void close () throws Exception {
			reader.close ();
		}
		
	}
}

