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;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, -1, 1};
const double eps = 1e-9;
const int INF = 0x7FFFFFFF;
const long long INFLL = 0x7FFFFFFFFFFFFFFFLL;
const double pi = acos(-1);
template <class T>
T take(queue<T> &O) {
  T tmp = O.front();
  O.pop();
  return tmp;
}
template <class T>
T take(stack<T> &O) {
  T tmp = O.top();
  O.pop();
  return tmp;
}
template <class T>
T take(priority_queue<T> &O) {
  T tmp = O.top();
  O.pop();
  return tmp;
}
inline void getint(int &num) { scanf("%d", &num); }
inline void getint(long long &num) { cin >> num; }
stack<char> sc;
stack<int> si;
string st;
int val[100005], le[100005];
int ans, l, r, tmp;
int main() {
  l = -1;
  r = -2;
  cin >> st;
  for (int(i) = (0), _t = ((int)st.size()); i < (_t); ++(i)) {
    {};
    char &c = st[i];
    int pos = i;
    if (c == '(' || c == '[') {
      sc.push(c);
      si.push(pos);
    } else if (c == ')') {
      if (sc.empty() || sc.top() != '(') {
        for (int(i) = (0), _t = ((int)sc.size()); i < (_t); ++(i)) {
          sc.pop();
          si.pop();
        }
      } else if (!sc.empty() && sc.top() == '(') {
        if (pos > 0) val[pos] += val[pos - 1];
        le[pos] = si.top();
        {};
        {};
        if (si.top() - 1 > 0 && val[si.top() - 1]) {
          val[pos] += val[si.top() - 1];
          le[pos] = le[si.top() - 1];
        }
        if (val[pos] > ans) {
          ans = val[pos];
          l = le[pos];
          r = pos;
        }
        sc.pop();
        si.pop();
      }
    } else if (c == ']') {
      if (sc.empty() || sc.top() != '[') {
        tmp = 0;
        for (int(i) = (0), _t = ((int)sc.size()); i < (_t); ++(i)) {
          sc.pop();
          si.pop();
        }
      } else if (!sc.empty() && sc.top() == '[') {
        ++val[pos];
        if (pos > 0) val[pos] += val[pos - 1];
        le[pos] = si.top();
        if (si.top() - 1 > 0 && val[si.top() - 1]) {
          val[pos] += val[si.top() - 1];
          le[pos] = le[si.top() - 1];
        }
        if (val[pos] > ans) {
          ans = val[pos];
          l = le[pos];
          r = pos;
        }
        sc.pop();
        si.pop();
      }
    }
  }
  cout << ans << endl;
  for (int(i) = (l), _t = (r); i <= (_t); ++(i)) cout << st[i];
  cout << endl;
  return 0;
}
