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.*;
import java.util.*;

public class Main {
	
	boolean can(char a, char b) {
		return (a == '(' && b == ')') || (a == '[' && b == ']');
	}
	
	void solve() {
		String s = in.next();
		int[] sum = new int[s.length() + 1];
		sum[0] = 0;
		for (int i = 0; i < s.length(); ++i) {
			sum[i + 1] = sum[i];
			if (s.charAt(i) == '[') {
				sum[i + 1] += 1;
			}
		}
		int[] st = new int[s.length()];
		int[] dp = new int[s.length() + 1];
		int[] pa = new int[s.length() + 1];
		int size = 0;
		dp[0] = 0;
		pa[0] = -1;
		for (int i = 0; i < s.length(); ++i) {
			dp[i + 1] = 0;
			pa[i + 1] = -1;
			if (s.charAt(i) == '(' || s.charAt(i) == '[') {
				st[size++] = i;
			} else {
				if (size > 0 && can(s.charAt(st[size - 1]), s.charAt(i))) {
					dp[i + 1] = sum[i + 1] - sum[st[size - 1]] + dp[st[size - 1]];
					pa[i + 1] = st[size - 1];
					--size;
				} else {
					size = 0;
				}
			}
		}
		int ans = 0;
		for (int i = 1; i <= s.length(); ++i) {
			ans = Math.max(ans, dp[i]);
		}
		out.println(ans);
		for (int i = 1; i <= s.length(); ++i) {
			if (dp[i] == ans) {
				ArrayList<Character> res = new ArrayList<>();
				while (pa[i] != -1) {
					for (int j = i; j > pa[i]; --j) {
						res.add(s.charAt(j - 1));
					}
					i = pa[i];
				}
				Collections.reverse(res);
				for (int j = 0; j < res.size(); ++j) {
					out.print(res.get(j));
				}
				out.println();
				return;
			}
		}
	}
	
	void run() {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}
	
	InputReader in;
	PrintWriter out;
	
	class InputReader {
		BufferedReader br;
		StringTokenizer st;
		
		InputReader(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			st = null;
		}
		
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}