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


public class ProblemA {

	public static void main(String[] args) throws IOException {
		new ProblemA().solve();
	}
	
	private void solve() throws IOException {
		
		
		Reader in = new Reader(System.in);
		PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
		
		String s = in.next();
		int N = s.length();
		
		boolean[] visited = new boolean[N];
		char[] stack = new char[N];
		int[] pos = new int[N];
		int idx = 0;
		
		for (int i = 0; i < N; i++) {
			char c = s.charAt(i);
			if (c == '(' || c == '[') {
				stack[idx] = c;
				pos[idx++] = i;
			} else {
				if (idx > 0) {
					if (c == ']') {
						if (stack[idx-1] == '[') {
							visited[i] = true;
							idx--;
							visited[pos[idx]] = true;
						} else {
							idx = 0;
						} 
					} else {
						if (stack[idx-1] == '(')  {
							visited[i] = true;
							idx--;
							visited[pos[idx]] = true;
						} else {
							idx = 0;
						} 
					}
				}
			}
		}
		
		int best = 0;
		int bestStart = 0;
		int bestEnd = 0;
		int current = 0;
		int currentStart = 0;
		for (int i = 0; i < N; i++) {
			if (!visited[i]) {
				if (current > best) {
					best = current;
					bestStart = currentStart;
					bestEnd = i;
					
				} 
				currentStart = i + 1;
				current = 0;
			} else {
				if (s.charAt(i) == '[') current++;
			}
		}
		if (current > best) {
			best = current;
			bestStart = currentStart;
			bestEnd = N;
		}
		out.println(best);
		if (best > 0) {
			out.println(s.substring(bestStart, bestEnd));
		}
		
		out.flush();
		out.close();
	}
	
	private static class Reader {
	    BufferedReader reader;
	    StringTokenizer tokenizer;

	    /** call this method to initialize reader for InputStream */
	    Reader(InputStream input) {
	        reader = new BufferedReader(
	                     new InputStreamReader(input) );
	        tokenizer = new StringTokenizer("");
	    }

	    /** get next word */
	    public String next() throws IOException {
	        while ( ! tokenizer.hasMoreTokens() ) {
	            //TODO add check for eof if necessary
	            tokenizer = new StringTokenizer(
	                   reader.readLine() );
	        }
	        return tokenizer.nextToken();
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt( next() );
	    }
		
	    public double nextDouble() throws IOException {
	        return Double.parseDouble( next() );
	    }
	    
	    public long nextLong() throws IOException {
	    	return Long.parseLong(next());
	    }
	    
	}
}
