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 INF = 1e9 + 10;
const long long int INFLL = 1e18 + 10;
const long double EPS = 1e-8;
const long double EPSLD = 1e-14;
const long long int MOD = 1000000007;
template <class T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <class T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
const int MAX_N = 100010;
char cs[MAX_N];
string s;
stack<int> st;
int cnt = 0;
int ansv;
int anss = 0;
int anse = 0;
int v[MAX_N];
int p[MAX_N];
int main() {
  for (int i = (0); i < (int)(MAX_N); i++) p[i] = i;
  scanf("%s", cs);
  s = cs;
  st.push(-1);
  for (int i = (0); i < (int)(s.length()); i++) {
    v[i] = cnt;
    if (s[i] == '(') st.push(i);
    if (s[i] == '[') st.push(i);
    if (s[i] == ')') {
      if (!st.empty() && s[st.top()] == '(') {
        if (cnt - v[p[st.top()]] > ansv) {
          ansv = cnt - v[p[st.top()]];
          anss = p[st.top()];
          anse = i + 1;
        }
        p[i + 1] = p[st.top()];
        st.pop();
      } else {
        cnt = 0;
        while (!st.empty()) st.pop();
      }
    } else if (s[i] == ']') {
      if (!st.empty() && s[st.top()] == '[') {
        p[i + 1] = p[st.top()];
        cnt++;
        if (cnt - v[p[st.top()]] > ansv) {
          ansv = cnt - v[p[st.top()]];
          anss = p[st.top()];
          anse = i + 1;
        }
        st.pop();
      } else {
        cnt = 0;
        while (!st.empty()) st.pop();
      }
    }
  }
  printf("%d\n", ansv);
  printf("%s\n", s.substr(anss, anse - anss).c_str());
  return 0;
}
