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.lang.*;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

public class Solution implements Runnable{
    public static BufferedReader br;
    public static PrintWriter out;
    public static StringTokenizer stk;
    public static boolean isStream = true;

    public static void main(String[] args) throws IOException {
    	if (isStream) {
            br = new BufferedReader(new InputStreamReader(System.in));
        } else {
            br = new BufferedReader(new FileReader("in.txt"));
        }
        out = new PrintWriter(System.out);
        new Thread(new Solution()).start();
    }

    public void loadLine() {
        try {
            stk = new StringTokenizer(br.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }

    public String nextWord() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return stk.nextToken();
    }

    public Integer nextInt() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Integer.valueOf(stk.nextToken());
    }

    public Long nextLong() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Long.valueOf(stk.nextToken());
    }

    public Double nextDouble() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Double.valueOf(stk.nextToken());
    }
    
    public Float nextFloat() {
        while (stk==null||!stk.hasMoreTokens()) loadLine();
        return Float.valueOf(stk.nextToken());
    }
    
    public void run() {
    	char[] arr = nextLine().toCharArray();
    	int n = arr.length;
    	int[] st = new int[n];
    	int a = 0;
    	int ans = 0;
    	int cans = 0;
    	int aa = 0;
    	int ab = 0;
    	int[] cnt = new int[n];
    	if (arr[0] == '[') cnt[0] = 1;
    	for (int i = 1; i < n; i++) {
    		cnt[i] = cnt[i-1];
    		if (arr[i] == '[') {
    			cnt[i]++;
    		}
    	}

    	int cc = 1;
    	st[0] = 0;
    	for (int i = 1; i < n; i++) {
    		if (arr[i] == '(' || arr[i] == '[') {
    			st[cc++] = i;
    		} else {
    			if (arr[i] == ')') {
    				if (cc > 0 && arr[st[cc-1]] == '(') {
    					cc--;
    				} else {
    					st[cc++] = i;
    				}
    			} else {
    				if (cc > 0 && arr[st[cc-1]] == '[') {
    					cc--;
    				} else {
    					st[cc++] = i;
    				}
    			}
				a = 0;
				if (cc > 0) a = st[cc-1]+1;
				cans = cnt[i];
				if (a > 0) cans -= cnt[a-1];
				if (cans > ans) {
					ans = cans;
					aa = a;
					ab = i;
				}
    		}
    	}
    	out.println(ans);
    	if (ans > 0) {
	    	for (int i = aa; i <= ab; i++) {
	    		out.print(arr[i]);
	    	}
    	}
    	out.println();
    	out.flush();
    }
}
