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;
template <class T>
inline void input(T &x) {
  register char c = getchar();
  x = 0;
  int neg = 0;
  for (; ((c < 48 || c > 57) && c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
inline long long bigmod(long long p, long long e, long long M) {
  long long ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
const int N = 1e5 + 5;
char s[N];
char cor(char c) {
  if (c == ')') return '(';
  if (c == '}') return '{';
  if (c == ']') return '[';
}
int P[N];
int main() {
  scanf("%s", s);
  for (int i = 0; s[i]; i++) {
    P[i] = (i > 0 ? P[i - 1] : 0);
    if (s[i] == '[') P[i]++;
  }
  stack<pair<char, int> > st;
  vector<pair<int, int> > Cor;
  for (int i = 0; s[i]; i++) {
    if (s[i] == '(' || s[i] == '{' || s[i] == '[') {
      st.push(make_pair(s[i], i));
    } else {
      int v = cor(s[i]);
      if (st.size() && st.top().first == v) {
        Cor.push_back(make_pair(st.top().second, i));
        st.pop();
      } else
        while (st.size()) st.pop();
    }
  }
  map<int, int> L, R;
  for (auto x : Cor) R[x.first] = x.second, L[x.second] = x.first;
  for (int i = 0; i < Cor.size(); i++) {
    int x = Cor[i].first, y = Cor[i].second;
    int l = x, r = y;
    if (L.count(x - 1)) l = min(l, L[x - 1]);
    if (R.count(y + 1)) r = max(r, R[y + 1]);
    L[y] = min(L[y], l);
    R[x] = max(R[x], r);
  }
  Cor.clear();
  for (auto x : L) Cor.push_back(make_pair(x.second, x.first));
  int ans = 0;
  pair<int, int> I = make_pair(1, 0);
  for (int i = 0; i < Cor.size(); i++) {
    int x = Cor[i].first, y = Cor[i].second;
    int v = P[y] - (x > 0 ? P[x - 1] : 0);
    if (v > ans) ans = v, I = Cor[i];
  }
  cout << ans << endl;
  for (int i = I.first; i <= I.second; i++) printf("%c", s[i]);
  return 0;
}
