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;
bool visit[2010][2010] = {};
vector<long long> vec[100001];
long long a[100001] = {};
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  stack<char> st;
  stack<int> sst;
  vector<long long> v[3];
  long long n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == '(' || s[i] == '[') {
      st.push(s[i]);
      sst.push(i);
    } else {
      if (st.empty()) continue;
      char t = st.top();
      if (s[i] == ']' && t == '[') {
        long long r = a[sst.top()] + 1;
        if (v[1].size() > 0 && v[1][v[1].size() - 1] == sst.top() - 1) {
          v[1][v[1].size() - 1] = i;
          v[2][v[1].size() - 1] += r;
        } else if (v[1].size() > 0 && v[0][v[0].size() - 1] > sst.top()) {
          v[0][v[1].size() - 1] = sst.top();
          v[1][v[1].size() - 1] = i;
          v[2][v[1].size() - 1] = r;
        } else {
          v[0].push_back(sst.top());
          v[1].push_back(i);
          v[2].push_back(r);
        }
        sst.pop();
        st.pop();
        if (!sst.empty()) {
          a[sst.top()] += r;
        }
      } else if (s[i] == ')' && t == '(') {
        long long r = a[sst.top()];
        if (v[1].size() > 0 && v[1][v[1].size() - 1] == sst.top() - 1) {
          v[1][v[1].size() - 1] = i;
          v[2][v[1].size() - 1] += r;
        } else if (v[1].size() > 0 && v[0][v[0].size() - 1] > sst.top()) {
          v[0][v[1].size() - 1] = sst.top();
          v[1][v[1].size() - 1] = i;
          v[2][v[1].size() - 1] = r;
        } else {
          v[0].push_back(sst.top());
          v[1].push_back(i);
          v[2].push_back(r);
        }
        sst.pop();
        st.pop();
        if (!sst.empty()) {
          a[sst.top()] += r;
        }
      } else {
        while (!st.empty()) {
          st.pop();
          sst.pop();
        }
      }
    }
  }
  n = v[0].size() - 1;
  for (int i = n; i > 0; i--) {
    if (v[0][i] - 1 == v[1][i - 1]) {
      v[1][i - 1] = v[1][i];
      v[2][i - 1] += v[2][i];
      v[2][i] = 0;
    } else if (v[0][i - 1] > v[0][i]) {
      v[0][i - 1] = v[0][i];
      v[1][i - 1] = v[1][i];
      v[2][i - 1] = v[2][i];
      v[2][i] = 0;
    }
  }
  for (int i = 0; i < n + 1; i++) {
  }
  long long index = -1;
  long long val = 0;
  for (int i = 0; i < v[0].size(); i++) {
    if (v[2][i] >= val) {
      index = i;
      val = v[2][i];
    }
  }
  if (index == -1) {
    cout << 0 << endl;
    return 0;
  }
  cout << val << endl;
  for (int i = v[0][index]; i <= v[1][index]; i++) cout << s[i];
}
