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
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
char a[100005];
int b[100005], maxv = -1, bestL, bestR, c[100005];
vector<pair<int, int> > v;
int main() {
  int i, j, k;
  gets(a);
  b[0] = (a[0] == '[');
  for (i = 1; a[i]; i++) {
    b[i] += b[i - 1];
    b[i] += (a[i] == '[');
  }
  stack<pair<char, int> > st;
  st.push(make_pair(a[0], 0));
  for (i = 1; a[i]; i++) {
    if (a[i] == '(' || a[i] == '[')
      st.push(make_pair(a[i], i));
    else if (a[i] == ')' && !st.empty() && st.top().first == '(') {
      if (v.size() > 0 && v.back().first > st.top().second &&
          v.back().second < i)
        v.back() = make_pair(st.top().second, i);
      else
        v.push_back(make_pair(st.top().second, i));
      int tmp = b[i];
      if (st.top().second > 0) tmp -= b[st.top().second - 1];
      if (maxv < tmp) {
        maxv = tmp;
        bestL = st.top().second;
        bestR = i;
      }
      st.pop();
    } else if (a[i] == ']' && !st.empty() && st.top().first == '[') {
      if (v.size() > 0 && v.back().first > st.top().second &&
          v.back().second < i)
        v.back() = make_pair(st.top().second, i);
      else
        v.push_back(make_pair(st.top().second, i));
      int tmp = b[i];
      if (st.top().second > 0) tmp -= b[st.top().second - 1];
      if (maxv < tmp) {
        maxv = tmp;
        bestL = st.top().second;
        bestR = i;
      }
      st.pop();
    } else
      st.push(make_pair(a[i], i));
  }
  sort(v.begin(), v.end());
  for (i = 0; i < v.size(); i++) {
    c[v[i].first]++;
    c[v[i].second + 1]--;
  }
  int len = strlen(a);
  for (i = 1; i < len; i++) c[i] += c[i - 1];
  for (i = 0; i < len;) {
    if (c[i] == 0) {
      i++;
      continue;
    }
    for (j = i; c[j] && j < len; j++)
      ;
    j--;
    int tmp = b[j];
    if (i > 0) tmp -= b[i - 1];
    if (tmp > maxv) {
      maxv = tmp;
      bestL = i;
      bestR = j;
    }
    i = j + 1;
  }
  if (maxv == -1)
    puts("0");
  else {
    printf("%d\n", maxv);
    a[bestR + 1] = 0;
    puts(a + bestL);
  }
  return 0;
}
