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 main() {
  string s;
  stack<int> q;
  int l, i, j, k = 0, r, max1 = 0, x, y;
  cin >> s;
  l = s.size();
  pair<int, int> p[l + 1];
  int a[l + 1];
  for (i = 0; i < l; i++) {
    if (i == 0)
      a[i] = 0;
    else
      a[i] = a[i - 1];
    if (s[i] == '[') a[i]++;
  }
  for (i = 0; i < l; i++) {
    if (s[i] == '(' || s[i] == '[') {
      q.push(i);
    } else {
      if (q.empty()) continue;
      j = q.top();
      if ((s[j] == '(' && s[i] == ')') || (s[j] == '[' && s[i] == ']')) {
        if (k > 0) {
          if (p[k - 1].second < i && p[k - 1].second > j) {
            p[k - 1] = make_pair(j, i);
            q.pop();
            continue;
          }
        }
        p[k] = make_pair(j, i);
        q.pop();
        k++;
      } else {
        while (!q.empty()) q.pop();
      }
    }
  }
  sort(p, p + k);
  l = p[0].first;
  r = p[0].second;
  for (i = 0; i < k - 1; i++) {
    if (r > p[i + 1].second) continue;
    if (r + 1 == p[i + 1].first)
      r = p[i + 1].second;
    else {
      int kol = a[r] - a[l];
      if (s[l] == '[') kol++;
      if (max1 < kol) {
        max1 = kol;
        x = l;
        y = r;
      }
      l = p[i + 1].first;
      r = p[i + 1].second;
    }
  }
  int kol = a[r] - a[l];
  if (s[l] == '[') kol++;
  if (max1 < kol) {
    max1 = kol;
    x = l;
    y = r;
  }
  if (x != y) {
    cout << max1 << endl;
    for (i = x; i <= y; i++) cout << s[i];
  } else
    cout << 0 << endl;
}
