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 static java.lang.Math.*;
import static java.util.Arrays.*;

import java.io.*;
import java.util.*;

public class A223 {

	final int MOD = 1000000007;
	final double eps = 1e-12;
	final int INF = (int)1e9;
	
	public A223 () throws IOException {
		char [] S = sc.nextChars();
		start();
		int N = S.length;

		int [] C = new int [N];
		fill(C, -1);

		Deque<Integer> LR = new LinkedList<Integer>(); 
		Deque<Integer> LS = new LinkedList<Integer>();
		
		for (int i = 0; i < N; ++i) {
			int lr = last(LR), ls = last(LS);
			switch(S[i]) {
			case '(': LR.add(i); break;
			case '[': LS.add(i); break;
			case ')': if (lr > ls) { C[lr] = i; LR.removeLast(); } else { LR.clear(); LS.clear(); } break;
			case ']': if (ls > lr) { C[ls] = i; LS.removeLast(); } else { LR.clear(); LS.clear(); } break;
			}
		}

		int L = -1;
		for (int i = 0; i < N; ++i) {
			L = max(L, C[i]);
			if (C[i] < L)
				C[i] = -1;
		}
		
		for (int i = 0; i < N; ++i) {
			while (C[i] > 0 && C[i]+1 < N && C[C[i]+1] > 0) {
				int j = C[i];
				C[i] = C[j+1];
				C[j+1] = -1;
			}
			if (C[i] > 0)
				i = C[i];
		}
		
		int Z = 0, I = -1;
		for (int i = 0; i < N; ++i)
			if (C[i] > 0) {
				int cnt = 0;
				for (int j = i; j <= C[i]; ++j)
					if (S[j] == '[')
						++cnt;
				if (cnt > Z) {
					Z = cnt;
					I = i;
				}
			}
		
		print(Z);
		exit(Z == 0 ? "" : new String(S, I, C[I]+1-I));
	}
	
	int last (Deque<Integer> L) {
		return L.isEmpty() ? -1 : L.peekLast();
	}
	
	void NO() {
		throw new Error("NO!");
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	static MyScanner sc;
	
	static class MyScanner {
		String next() throws IOException {
			newLine();
			return line[index++];
		}
		
		char nextChar() throws IOException {
			return next().charAt(0);
		}
				
		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		
		long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		
		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		String nextLine() throws IOException {
			line = null;
			return r.readLine();
		}
		
		String [] nextStrings() throws IOException {
			line = null;
			return r.readLine().split(" ");
		}
		
		char [] nextChars() throws IOException {
			return next().toCharArray();
		}

		int [] nextInts() throws IOException {
			String [] L = nextStrings();
			int [] res = new int [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Integer.parseInt(L[i]);
			return res;
		}	
		
		long [] nextLongs() throws IOException {
			String [] L = nextStrings();
			long [] res = new long [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Long.parseLong(L[i]);
			return res;
		}

		double [] nextDoubles() throws IOException {
			String [] L = nextStrings();
			double [] res = new double [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Double.parseDouble(L[i]);
			return res;
		}

		boolean eol() {
			return index == line.length;
		}

		//////////////////////////////////////////////
		
		private final BufferedReader r;

		MyScanner () throws IOException {
			this(new BufferedReader(new InputStreamReader(System.in)));
		}
		
		MyScanner(BufferedReader r) throws IOException { 
			this.r = r;
		}
		
		private String [] line;
		private int index;

		private void newLine() throws IOException {
			if (line == null || eol()) {
				line = r.readLine().split(" ");
				index = 0;
			}
		}		
	}
	
	static PrintWriter pw = new PrintWriter(System.out);
	
	static void print (Object... a) {
		StringBuilder b = new StringBuilder();
		for (Object o : a)
			b.append(" ").append(o);
		pw.println(b.toString().trim());
	}

	static void exit (Object... a) {
		print(a);
		exit();
	}

	static void exit () {
		pw.flush();
		System.err.println("------------------");
		System.err.println("Time: " + secs());
		System.exit(0);
	}
	
	////////////////////////////////////////////////////////////////////////////////////
	
	public static void main(String[] args) throws IOException {
		run();
		exit();
	}

	static void start() {
		t = millis();
	}

	static void run () throws IOException {
		sc = new MyScanner ();
		new A223();
	}

	static long t;
	
	static long millis() {
		return System.currentTimeMillis();
	}	

	static double secs() {
		return (millis() - t) / 1000.0;
	}
}
