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 MAXN = 500000 + 10;
char s[MAXN];
int ans[MAXN][2], qu[MAXN], l[MAXN], r[MAXN], f[MAXN];
int gs, he, ta, n;
void rd(int i) {
  if (i < 0) return;
  if (l[l[i]] < 0)
    ans[gs][0] = 0;
  else
    ans[gs][0] = l[l[i]] + 1;
  if (r[i] < 0)
    ans[gs][1] = n - 1;
  else
    ans[gs][1] = r[i] - 1;
  gs++;
  qu[++ta] = i;
}
bool check(int i) {
  if (i < 0) return false;
  if ((s[i] == ')') && (s[l[i]] == '(')) return true;
  if ((s[i] == ']') && (s[l[i]] == '[')) return true;
  return false;
}
int main() {
  int i, j, pr, x, k;
  scanf("%s", s);
  memset(l, 0, sizeof(l));
  ;
  memset(r, 0, sizeof(r));
  ;
  for (n = 0; s[n]; n++)
    ;
  for (i = 0; i < n; i++) {
    l[i] = i - 1;
    r[i] = i + 1;
  }
  l[0] = -1;
  r[n - 1] = -1;
  he = 0;
  ta = 0;
  gs = 0;
  for (i = 1; i < n; i++) {
    if (check(i)) rd(i);
  }
  while (he < ta) {
    x = qu[++he];
    if (r[x] >= 0) l[r[x]] = l[l[x]];
    if (l[l[x]] >= 0) r[l[l[x]]] = r[x];
    if (l[l[x]] < 0)
      ans[gs][0] = 0;
    else
      ans[gs][0] = l[l[x]] + 1;
    if (r[x] < 0)
      ans[gs][1] = n - 1;
    else
      ans[gs][1] = r[x] - 1;
    gs++;
    if (check(r[x])) rd(r[x]);
  }
  j = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == '[') j++;
    f[i] = j;
  }
  int ax, ay;
  pr = 0;
  for (i = 0; i < gs; i++) {
    if (ans[i][0] == 0)
      k = f[ans[i][1]];
    else
      k = f[ans[i][1]] - f[ans[i][0] - 1];
    if (k > pr) {
      pr = k;
      ax = ans[i][0];
      ay = ans[i][1];
    }
  }
  printf("%d\n", pr);
  if (pr > 0) {
    for (i = ax; i <= ay; i++) printf("%c", s[i]);
  }
  return 0;
}
