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;
string s;
int n, al = -1, ar = -1, mx = 0;
vector<char> st;
int sum[100100], last[100100];
void tryOut(int l, int r) {
  if (mx < sum[r] - sum[l]) {
    mx = sum[r] - sum[l];
    al = l;
    ar = r;
  }
}
int solve(int l) {
  st.clear();
  last[0] = l;
  for (int i = l; i < n; ++i) {
    if (s[i] == ')') {
      if (st.size() && st.back() == '(') {
        st.pop_back();
        tryOut(last[st.size()], i + 1);
      } else {
        return i + 1;
      }
    } else if (s[i] == ']') {
      if (st.size() && st.back() == '[') {
        st.pop_back();
        tryOut(last[st.size()], i + 1);
      } else {
        return i + 1;
      }
    } else {
      st.push_back(s[i]);
      last[st.size()] = i + 1;
    }
  }
  return n;
}
int main() {
  cin >> s;
  n = s.size();
  sum[0] = 0;
  for (int i = 0; i < (int)(n); ++i) {
    sum[i + 1] = sum[i] + (s[i] == '[');
  }
  int cur = 0;
  while (cur < n) {
    cur = solve(cur);
  }
  if (al == -1) {
    cout << 0;
    return 0;
  }
  cout << mx << endl;
  for (int i = al; i < ar; ++i) {
    cout << s[i];
  }
}
