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 MN = 1e5 + 100;
int st[MN];
inline int getSum(int a, int b) { return st[b + 1] - st[a]; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  s.push_back('[');
  s.insert(s.begin(), ']');
  list<pair<int, int> > lt;
  for (int i = 0; i < s.size(); ++i) {
    lt.push_back({s[i], i});
    if (s[i] == '[') {
      st[i + 1] = 1;
    }
    st[i + 1] += st[i];
  }
  list<pair<int, int> >::iterator it = lt.begin();
  int lol = 0;
  int siz = lt.size();
  while (siz > 1 && it != lt.end()) {
    list<pair<int, int> >::iterator it2 = it;
    ++it2;
    if (it2 == lt.end()) break;
    if (it->first == '(' && it2->first == ')') {
      it = lt.erase(it);
      it = lt.erase(it);
      siz -= 2;
      if (it != lt.begin() && !lt.empty()) --it;
    } else if (it->first == '[' && it2->first == ']') {
      it = lt.erase(it);
      it = lt.erase(it);
      siz -= 2;
      if (it != lt.begin() && !lt.empty()) --it;
    } else {
      ++it;
    }
  }
  int ma = 0;
  if (lt.size() == 0) {
    cout << getSum(0, s.size() - 1) << '\n';
    cout << s << '\n';
    return 0;
  }
  it = lt.begin();
  while (it != lt.end()) {
    list<pair<int, int> >::iterator it2 = it;
    ++it2;
    if (it2 == lt.end()) break;
    ma = max(ma, getSum(it->second + 1, it2->second - 1));
    ++it;
  }
  if (ma == 0) {
    cout << 0 << '\n';
    return 0;
  }
  it = lt.begin();
  while (it != lt.end()) {
    list<pair<int, int> >::iterator it2 = it;
    ++it2;
    if (it2 == lt.end()) break;
    if (getSum(it->second + 1, it2->second - 1) == ma) {
      cout << ma << '\n';
      for (int i = it->second + 1; i < it2->second; ++i) {
        cout << s[i];
      }
      cout << '\n';
      return 0;
    }
    ++it;
  }
  cout << 0 << '\n';
}
