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 = 100005;
char s[maxn];
map<pair<int, int>, int> pos;
struct state {
  int pos;
  int c1, c2;
  state() {}
  state(int pos_, int c1_, int c2_) : pos(pos_), c1(c1_), c2(c2_) {}
};
int c1, c2;
int n;
state st[maxn];
int stc;
int cm[maxn];
void initcm() {
  for (int i = 0; i < n; i++) {
    cm[i + 1] = cm[i];
    if (s[i] == '[') ++cm[i + 1];
  }
}
int get(int l, int r) { return cm[r + 1] - cm[l]; }
bool isbetter(int l1, int r1, int l2, int r2) {
  return get(l1, r1) >= get(l2, r2);
}
int f1[maxn];
int f2[maxn];
const int inf = 100000000;
void feninit(int* f) {
  for (int i = 0; i <= n; i++) {
    f[i] = inf;
  }
}
void fenset(int* f, int k, int v) {
  while (k <= n) {
    f[k] = min(f[k], v);
    int d = ((k ^ (k - 1)) >> 1) + 1;
    k += d;
  }
}
int fenget(int* f, int k) {
  int res = inf;
  while (k > 0) {
    res = min(res, f[k]);
    int d = ((k ^ (k - 1)) >> 1) + 1;
    k -= d;
  }
  return res;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  feninit(f1);
  feninit(f2);
  initcm();
  pos[make_pair(0, 0)] = 0;
  int i = 0;
  int bl = 0;
  int br = 0;
  for (i = 0; i < n; i++) {
    char c = s[i];
    if (c == '(') {
      st[stc++] = state(i, c1, c2);
      ++c1;
    } else if (c == ')') {
      if (stc == 0) {
        fenset(f1, n - i, -inf);
      } else {
        state prev = st[--stc];
        if (s[prev.pos] != '(' || prev.c2 != c2) {
          stc = 0;
          fenset(f1, n - i, -inf);
        }
        --c1;
      }
    } else if (c == '[') {
      st[stc++] = state(i, c1, c2);
      ++c2;
    } else if (c == ']') {
      if (stc == 0) {
        fenset(f1, n - i, -inf);
      } else {
        state prev = st[--stc];
        if (s[prev.pos] != '[' || prev.c1 != c1) {
          stc = 0;
          fenset(f1, n - i, -inf);
        }
        --c2;
      }
    }
    pair<int, int> ss = make_pair(c1, c2);
    if (pos.find(ss) != pos.end()) {
      int ps = pos[ss];
      if (fenget(f1, n - ps) < c1 || fenget(f2, n - ps) < c2) {
        pos[ss] = i + 1;
      } else if (isbetter(pos[ss], i, bl, br)) {
        bl = pos[ss];
        br = i;
      }
    } else {
      pos[ss] = i + 1;
    }
    fenset(f1, n - i, c1);
    fenset(f2, n - i, c2);
  }
  if (bl || br) {
    printf("%d\n", get(bl, br));
    s[br + 1] = 0;
    printf("%s\n", s + bl);
  } else {
    printf("0\n");
  }
  return 0;
}
