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.PrintWriter;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class A {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		String s = sc.next();
		int n = s.length();
		int[] good = new int[n];
		Stack<Pair> st = new Stack<Pair>();
		for(int i = 0; i < n; ++i)
		{
			char c = s.charAt(i);
			if(c == '(' || c == '[')
				st.push(new Pair(i, c));
			else if(!st.isEmpty() && st.peek().c == rev(c))
				good[st.pop().idx] =  good[i] = 1;
			else
				st.clear();
		}
		int ans = 0, idx = -1, len = -1;
		for(int i = 0; i < n; ++i)
			if(good[i] == 1)
			{
				int lst = i, cnt = 0;
				while(lst < n && good[lst] == 1)
					if(s.charAt(lst++) == '[')
						++cnt;
				if(cnt > ans)
				{
					ans = cnt;
					idx = i;
					len = lst - idx;
				}
				i = lst - 1;
			}
		out.println(ans);
		if(ans != 0)
			out.println(s.substring(idx, idx + len));
		out.flush();
		out.close();
	}
	
	static class Pair
	{
		int idx;
		char c;
		
		Pair(int a, char b) { idx = a; c = b; }
	}
	
	static char rev(char c) { return c == ')' ? '(' : '['; }
	
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {return br.readLine();}

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

		public boolean ready() throws IOException {return br.ready();} 
	}
} 