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.util.Scanner;

public class BracketSequence 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		boolean debug = false;
		
		int depth = 0; //(
		int[] checkpoint = new int[100001];
		int[] depthscore = new int[100001];
		int[] dsrun = new int[100001];
		boolean[] depthtype = new boolean[100001]; //false: (
		
		int best = 0;
		int scr = 0;
		int run = 0;
		
		int beststart = -1;
		int bestend = -1;
		int bestsafe = -1;
		int cpm = 0;
		
		for(int i = 0; i < s.length(); i++)
		{
			char c = s.charAt(i);
			
			
			if(c == '(')
			{
				depthtype[depth] = false;
				depthscore[depth] = scr;
				dsrun[depth] = run;
				scr = 0;
				checkpoint[depth] = i;
//				System.out.println("Set checkpoint for depth " + depth);
				depth++;
			}
			else if(c == '[')
			{
				depthtype[depth] = true;
				depthscore[depth] = scr;
				dsrun[depth] = run;
				scr = 0;
				checkpoint[depth] = i;
//				System.out.println("Set checkpoint for depth " + depth);
				depth++;
			}
			else if(c == ')')
			{
				depth--;
				if(depth >= 0 && depthtype[depth] == false)
				{
					if(dsrun[depth] == run)
					{
//						System.out.println("Take out loan " + depthscore[depth]);
						scr += depthscore[depth];
						depthscore[depth] = 0;
						
						if(scr > best)
						{
//							System.out.println(i + " new best " + scr);
							best = scr;
							bestend = i;
							
							if(depth-1 >= 0)
								beststart = checkpoint[depth-1]+1;
							else
								beststart = cpm;
						}						
					}
					
				}
				else
				{ //mismatch or excess
					run++;
					depth = 0;
					scr = 0;
					cpm = i+1;
				}
			}
			else if(c == ']')
			{
				depth--;
				if(depth >= 0 && depthtype[depth] == true)
				{
					if(dsrun[depth] == run)
					{
//						System.out.println("Take out loan " + depthscore[depth]);
						scr += depthscore[depth];
						depthscore[depth] = 0;
					}
					
					scr++;
					if(scr > best)
					{
						best = scr;
						bestend = i;
						
						if(depth-1 >= 0)
							beststart = checkpoint[depth-1]+1;
						else
							beststart = cpm;
					}
				}
				else
				{ //mismatch or excess
					run++;
					depth = 0;
					scr = 0;
					cpm = i+1;
				}
			}
			
		}
		
		System.out.println(best);
		if(best > 0)
			System.out.println(s.substring(beststart, bestend+1));
		else
			System.out.println("");
	}

}
