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;
int csum[100005];
bool check[100005];
string s;
void doCsum() {
  for (int i = 1; i < s.length(); i++) csum[i] += csum[i - 1];
}
bool isRight(char x, char y) {
  if ((x == '(' && y == ')') || (x == '[' && y == ']'))
    return true;
  else
    return false;
}
int main() {
  cin >> s;
  for (int i = 0; i < s.length(); i++)
    if (s[i] == '[') csum[i] = 1;
  doCsum();
  stack<int> st;
  vector<pair<int, int> > v;
  vector<pair<int, int> > f;
  vector<pair<int, int> > a;
  bool flag = true;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '(' || s[i] == '[')
      st.push(i);
    else {
      if (!st.empty() && isRight(s[st.top()], s[i])) {
        v.push_back({st.top(), i});
        st.pop();
      } else {
        st = stack<int>();
      }
    }
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    int j = i;
    while (true) {
      if (v[i + 1].first > v[j].first && v[i + 1].second < v[j].second) {
        check[i + 1] = true;
        i++;
        if (i == v.size() - 1) break;
      } else
        break;
    }
  }
  for (int i = 0; i < v.size(); i++) {
    if (check[i] == false) f.push_back({v[i].first, v[i].second});
  }
  memset(check, 0, sizeof(check));
  int temp = 0;
  for (int i = 0; i < (int)f.size() - 1; i++) {
    if (f[i].second == f[i + 1].first - 1) {
      check[i + 1] = true;
      if (i + 1 == f.size() - 1) {
        f[temp].second = f[i + 1].second;
      }
    } else {
      f[temp].second = f[i].second;
      temp = i + 1;
    }
  }
  for (int i = 0; i < f.size(); i++) {
    if (check[i] == false) a.push_back({f[i].first, f[i].second});
  }
  int MAX = 0;
  int r, l;
  for (int i = 0; i < a.size(); i++) {
    if (f[i].first == 0)
      temp = csum[a[i].second];
    else
      temp = csum[a[i].second] - csum[a[i].first - 1];
    if (temp > MAX) {
      MAX = temp;
      r = a[i].first;
      l = a[i].second;
    }
  }
  if (f.size() == 0)
    cout << "0" << endl;
  else {
    cout << MAX << endl;
    for (int i = r; i <= l; i++) cout << s[i];
    cout << endl;
  }
}
