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>
using namespace std;
char St[100007];
stack<pair<char, int> > S1;
stack<pair<int, int> > S2;
vector<pair<int, int> > V;
int Pre[100007];
int main() {
  int i, j, k, l, m, n, x, y, z, a, b, r, ans;
  scanf("%s", St);
  n = strlen(St);
  for (i = 0; i < n; i++) {
    if ((S1.empty()) || (St[i] == '(' || St[i] == '[')) {
      S1.push(make_pair(St[i], i + 1));
    } else {
      if ((S1.top().first == '(' && St[i] == ')') ||
          (S1.top().first == '[' && St[i] == ']')) {
        x = S1.top().second;
        y = i + 1;
        S1.pop();
        while (!S2.empty() && x <= S2.top().first && S2.top().second <= y)
          S2.pop();
        S2.push(make_pair(x, y));
      } else {
        S1.push(make_pair(St[i], i + 1));
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (St[i - 1] == '[') Pre[i] = 1;
    Pre[i] += Pre[i - 1];
  }
  ans = 0;
  while (!S2.empty()) {
    V.push_back(S2.top());
    S2.pop();
  }
  reverse(V.begin(), V.end());
  for (i = 0; i < (int)V.size(); i++) {
    if (S2.empty())
      S2.push(V[i]);
    else {
      if (S2.top().second + 1 == V[i].first) {
        x = S2.top().first;
        y = V[i].second;
        S2.pop();
        S2.push(make_pair(x, y));
      } else {
        S2.push(V[i]);
      }
    }
  }
  x = y = 0;
  while (!S2.empty()) {
    if (ans < Pre[S2.top().second] - Pre[S2.top().first - 1]) {
      ans = Pre[S2.top().second] - Pre[S2.top().first - 1];
      x = S2.top().first;
      y = S2.top().second;
    }
    S2.pop();
  }
  printf("%d\n", ans);
  St[y] = '\0';
  if (ans != 0) printf("%s\n", St + x - 1);
  return 0;
}
