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;
struct S {
  int cnt;
  int pos;
  char br;
  S(int cnt = 0, int pos = 0, char br = 0) : cnt(cnt), br(br), pos(pos){};
};
string s;
int n;
pair<int, int> a[int(1e5) + 10];
int isEnd[int(1e5) + 10];
void task() {
  ios_base::sync_with_stdio(0);
  fill(a, a + int(1e5) + 10, make_pair(-1, -1));
  cin >> s;
  n = s.length();
  stack<S> st;
  int i = 0;
  while (i < n && (s[i] == ']' || s[i] == ')')) ++i;
  if (i == n) {
    cout << 0 << "\n";
    return;
  }
  st.push(S(s[i] == '[', i, s[i]));
  ++i;
  for (; i < n; ++i) {
    if (s[i] == ']') {
      if (st.empty()) continue;
      if (st.top().br != '[') {
        while (!st.empty()) st.pop();
        continue;
      }
      S p = st.top();
      st.pop();
      if (!st.empty())
        st.top().cnt += p.cnt;
      else
        isEnd[i] = 1;
      a[i].first = p.cnt;
      a[i].second = p.pos;
    }
    if (s[i] == ')') {
      if (st.empty()) continue;
      if (st.top().br != '(') {
        while (!st.empty()) st.pop();
        continue;
      }
      S p = st.top();
      st.pop();
      if (!st.empty())
        st.top().cnt += p.cnt;
      else
        isEnd[i] = 1;
      a[i].first = p.cnt;
      a[i].second = p.pos;
    }
    if (s[i] == '[') {
      st.push(S(1, i, s[i]));
    }
    if (s[i] == '(') {
      st.push(S(0, i, s[i]));
    }
  }
  for (int i = 0; i < n; ++i)
    if (a[i].second - 1 >= 0) {
      int to = a[i].second - 1;
      if (a[to].second != -1) {
        a[i].first += a[to].first;
        a[i].second = a[to].second;
      }
    }
  int id = -1;
  for (int i = 0; i < n; ++i)
    if (a[i].first != -1)
      if (id == -1 || a[i].first > a[id].first) id = i;
  if (id == -1)
    cout << 0;
  else
    cout << a[id].first << "\n"
         << s.substr(a[id].second, id - a[id].second + 1);
}
int main() {
  task();
  return 0;
}
