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.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.Stack;

public class CF223A {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.next();
		int[] nBrackets = new int[in.length()+1];
		Stack<StackElement> s = new Stack<>();
		ArrayList<Point> points = new ArrayList<>();
		for(int i=0; i<in.length(); i++) {
			char c = in.charAt(i);
			if(c=='[') nBrackets[i+1]++;
			if(i>0) nBrackets[i+1]+=nBrackets[i];
			if(c=='(' || c=='[') {
				s.push(new StackElement(c, i));
			} else if(c==')') {
				if(!s.isEmpty()) {
					if(s.peek().c=='(') {
						points.add(new Point(s.peek().index, i));
						s.pop();
					} else s = new Stack<>();
				}
			} else {
				if(!s.isEmpty()) { 
					if(s.peek().c=='[') {
						points.add(new Point(s.peek().index, i));
						s.pop();
					} else s = new Stack<>();
				}
			}
		}
		Collections.sort(points);
		ArrayList<Point> cleanedPoints = new ArrayList<>();
		int curEnd = -1;
		for(int i=0; i<points.size(); i++) {
			if(points.get(i).start>curEnd) {
				curEnd = points.get(i).end;
				cleanedPoints.add(points.get(i));
			}
		}
		points = cleanedPoints;
		boolean didMerge = false;
		for(int i=0; i<points.size(); i++) {
			if(i<points.size()-1) {
				if(points.get(i).end+1==points.get(i+1).start) {
					points.get(i+1).start = points.get(i).start;
					points.remove(i);
					i--;
				}
			}
		}
		int best = 0;
		Point bestPoint = null;
		for(int i=0; i<cleanedPoints.size(); i++) {
			Point curP = cleanedPoints.get(i);
			int curBest = nBrackets[curP.end+1]-nBrackets[curP.start];
			if(curBest>best) {
				best = curBest;
				bestPoint = cleanedPoints.get(i);
			}
		}
		System.out.println(best);
		System.out.println(bestPoint==null ? "" : in.substring(bestPoint.start, bestPoint.end+1));
		//---------------------------------------------------------- OLD SHIT
		/*
		int best = 0;
		String ans = "";
		Stack<Character> s = new Stack<>();
		StringBuilder curAns = new StringBuilder();
		for(int i=0; i<in.length(); i++) {
			// System.out.println("DEBUG "+ans+best);
			char c = in.charAt(i);
			if(c=='(' || c=='[') {
				s.push(c);
				curAns.append(c);
			} else if(c==')') {
				if(s.isEmpty()) {
					curAns = new StringBuilder();
				} else if(s.peek()=='(') {
					s.pop();
					curAns.append(c);
				} else {
					s = new Stack<>();
					curAns = new StringBuilder();
				}
			} else {
				if(s.isEmpty()) {
					curAns = new StringBuilder();
				} else if(s.peek()=='[') {
					s.pop();
					curAns.append(c);
					String temp = reverse(getLongestValid(reverse(curAns.toString())));
					int curBest = countOpenBrackets(temp);
					if(curBest>best) {
						best = curBest;
						ans = temp;
					}
				} else {
					s = new Stack<>();
					curAns = new StringBuilder();
				}
			}
		}
		System.out.println(best);
		System.out.println(ans);
		*/
	}
	
	static class Point implements Comparable<Point> {
		int start;
		int end;
		
		public Point(int a, int b) {
			start = a;
			end = b;
		}

		@Override
		public int compareTo(Point o) {
			return Integer.compare(this.start, o.start);
		}
	}
	
	static class StackElement {
		char c;
		int index;
		
		public StackElement(char c, int index) {
			this.c = c;
			this.index = index;
		}
	}
	/*
	private static int countOpenBrackets(String s) {
		int total = 0;
		for(int i=0; i<s.length(); i++) if(s.charAt(i)=='[') total++;
		return total;
	}

	static String reverse(String in) {
		String r = new StringBuilder(in).reverse().toString();
		StringBuilder extra = new StringBuilder();
		for(int i=0; i<r.length(); i++) 
			extra.append(r.charAt(i)=='(' ? ')' :
							r.charAt(i)==')' ? '(' :
							r.charAt(i)=='[' ? ']' :
							r.charAt(i)==']' ? '[' :
							r.charAt(i));
		return extra.toString();
	}
	
	static String getLongestValid(String in) {
		StringBuilder sb = new StringBuilder();
		Stack<Character> s = new Stack<>();
		for(int i=0; i<in.length(); i++) {
			char c = in.charAt(i);
			if(c=='(' || c=='[') {
				s.add(c);
				sb.append(c);
			} else if(c==')') {
				if(s.isEmpty()) break;
				if(s.peek()=='(') {
					s.pop();
					sb.append(c);
				} else {
					sb.setLength(sb.length()-1);
					break;
				}
			} else {
				if(s.isEmpty()) break;
				if(s.peek()=='[') {
					s.pop();
					sb.append(c);
				} else {
					sb.setLength(sb.length()-1);
					break;
				}
			}
		}
		return sb.toString();
	}
	*/
}
