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 N = 240000 + 20;
char s[N];
int n, m;
int z[N], g2[N];
int ans[3], now[3];
int M[220][220];
struct node {
  int l, r;
  node() {}
  node(int p, int q) : l(p), r(q) {}
  bool operator<(const node& a) const {
    return (l < a.l || (l == a.l && r > a.r));
  }
} a[100000], b[100000];
int main() {
  memset(M, 0, sizeof(M));
  M['('][')'] = 1;
  M['['][']'] = 1;
  while (scanf("%s", s + 1) == 1) {
    int nn = 0;
    n = strlen(s + 1);
    z[0] = z[1] = 1;
    for (int i = 2; i <= n; ++i) {
      if (z[0] > 0 && M[s[z[z[0]]]][s[i]] == 1) {
        a[++nn] = node(z[z[0]], i);
        --z[0];
      } else {
        z[++z[0]] = i;
        if (s[i] == ')' || s[i] == ']') z[0] = 0;
      }
    }
    if (!nn) {
      puts("0");
      continue;
    }
    memset(g2, 0, sizeof(g2));
    for (int i = 1; i <= n; ++i) g2[i] = g2[i - 1] + (s[i] == '[');
    memset(z, 0, sizeof(z));
    for (int i = 1; i <= nn; ++i) z[a[i].l] = z[a[i].r] = 1;
    nn = 0;
    for (int i = 1; i <= n; ++i)
      if (z[i] == 1) {
        int l = i;
        while (i <= n && z[i] == 1) ++i;
        --i;
        a[++nn] = node(l, i);
      }
    ans[0] = -1;
    for (int i = 1; i <= nn; ++i)
      if (ans[0] < g2[a[i].r] - g2[a[i].l - 1]) {
        ans[0] = g2[a[i].r] - g2[a[i].l - 1];
        ans[1] = a[i].l;
        ans[2] = a[i].r;
      }
    printf("%d\n", ans[0]);
    for (int i = ans[1]; i <= ans[2]; ++i) printf("%c", s[i]);
    puts("");
  }
  return 0;
}
