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

// Solution

public class Main 
{    
  public static void main (String[] argv) 
  {
	  new Main();
  } 
     
  
  boolean test = false;
  
  
  public Main() {
	  FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
	  //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));
      char[] a = in.next().toCharArray();
      int n = a.length;
      int[] left = new int[n];  // left[i]:   range [left[i], i] is  the longest interval such that it is valid
      int[] cnt = new int[n];   // number of [  in range [left[i], i] 
      // if not valie left[i] = INVALID
      final int INVALID = -1;      
      int maxCnt = 0;
      int bestI = -1;
      
      for (int i = 0; i < n; i++) {
          char c = a[i];
          if (c == '(' || c == '[') left[i] = INVALID;
          else {
             if (i > 0 && match(a[i-1], c)) {
                 left[i] = i - 1;
                 int curCnt = 0;
                 if (i - 2 >= 0 && left[i-2] >= 0) {
                     left[i] = left[i-2];
                     curCnt = cnt[i-2];
                 }
                 if (c == ']') {
                     curCnt++;                     
                 }
                 if (curCnt > maxCnt) {
                     maxCnt = curCnt;
                     bestI = i;
                 }
                 cnt[i] = curCnt;
             }else if (i > 0 && left[i-1] > 0 && match(a[ left[i-1] - 1], c)) {
                 left[i] = left[i-1] - 1;
                 int curCnt = cnt[i-1];
                 if (left[i] > 0 && left[ left[i] - 1] >= 0) {                     
                     curCnt += cnt[left[i] - 1];
                     left[i] = left[ left[i] - 1];
                 }
                 if (c == ']') {
                     curCnt++;                     
                 }
                 if (curCnt > maxCnt) {
                     maxCnt = curCnt;
                     bestI = i;
                 }
                 cnt[i] = curCnt;
             }else {
                 left[i] = INVALID;
             }
         
          }
      }
      
      System.out.println(maxCnt);
      if (maxCnt > 0) {
          for (int i = left[bestI]; i <= bestI; ++i) System.out.print(a[i]);
          System.out.println();
      }
  }
  
  private boolean match(char l, char r) {
      return (l == '(' && r == ')')  || (l == '[' && r == ']');
  }
  private int max(int a, int b) {
      return a >  b ? a : b;
  }
  
  private int min(int a, int b) {
      return a >  b ? b : a;
  }
  
  
  static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader(BufferedReader in)
        {            
            br = in;
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    String line = br.readLine();
                    if (line == null || line.length() == 0) return "";
                    st = new StringTokenizer(line);
                }
                catch (IOException  e)
                {
                    return "";
                    //e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                return "";
                //e.printStackTrace();
            }
            return str;
        }
    }
}