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;
char a[100005];
char b[100005];
int dp[100005];
int d[100005], p[100005];
int rx, ry;
int c[100005];
int res;
int i, j, k, n, m, x, y, z, t;
int main() {
  cin >> a;
  n = strlen(a);
  m = 0;
  res = -1;
  memset(d, -1, sizeof(d));
  memset(dp, -1, sizeof(dp));
  for (i = 0; i < n; i++) {
    if (a[i] == '(' || a[i] == '[') {
      c[m] = i;
      b[m++] = a[i];
    } else if ((a[i] == ')' && m > 0 && b[m - 1] == '(') ||
               (a[i] == ']' && m > 0 && b[m - 1] == '[')) {
      m--;
      p[i] = c[m];
      dp[i] = (a[i] == ']');
      if (a[i - 1] == ']' || a[i - 1] == ')') {
        dp[i] += dp[i - 1];
      }
    } else {
      m = 0;
      t = 0;
    }
    if (dp[i] != -1) {
      x = p[i] - 1;
      if (x >= 0 && dp[x] > 0) {
        dp[i] += dp[x];
        p[i] = p[x];
      }
    }
    if (dp[i] > res) {
      res = dp[i];
      rx = p[i];
      ry = i;
    }
  }
  if (res == -1) {
    cout << 0 << endl;
    return 0;
  } else if (res == 0) {
    cout << res << endl;
    cout << "()" << endl;
    return 0;
  }
  cout << res << endl;
  for (i = rx; i <= ry; i++) {
    cout << a[i];
  }
  cout << endl;
  return 0;
}
