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 inline ABS(int a) {
  if (a > 0)
    return a;
  else
    return -a;
}
int GCD(int a, int b) {
  if (!a) return b;
  return GCD(b % a, a);
}
stack<pair<int, char> > S;
int M[100009];
int count(int a, int b) {
  if (a == -1 || b == -1) return 0;
  int end, start;
  if (a == 0)
    start = 0;
  else
    start = M[a - 1];
  assert(b != 0);
  end = M[b];
  return end - start;
}
vector<pair<int, int> > seq;
int main() {
  string str;
  cin >> str;
  int ms = 0, st = -1, end = -1, last = 0, ls = -1, le = -1;
  if (str[0] == '[') M[0] = 1;
  for (int i = 1; str[i]; i++) {
    if (str[i] == '[') {
      M[i] = M[i - 1] + 1;
    } else
      M[i] = M[i - 1];
  }
  for (int i = 0; str[i]; i++) {
    if (S.empty()) {
      S.push(make_pair(i, str[i]));
      continue;
    }
    if (str[i] == '[') {
      S.push(make_pair(i, str[i]));
    }
    if (str[i] == '(') {
      S.push(make_pair(i, str[i]));
    }
    if (str[i] == ']') {
      if (S.top().second == '[') {
        st = S.top().first;
        end = i;
        S.pop();
        seq.push_back(make_pair(st, end));
      } else {
        S.push(make_pair(i, str[i]));
      }
    }
    if (str[i] == ')') {
      if (S.top().second == '(') {
        st = S.top().first;
        end = i;
        seq.push_back(make_pair(st, end));
        S.pop();
      } else {
        S.push(make_pair(i, str[i]));
      }
    }
  }
  sort(seq.begin(), seq.end());
  for (int i = 0; i < seq.size(); i++) {
    if (i != 0) {
      if (seq[i].first <= seq[i - 1].second + 1) {
        seq[i].first = seq[i - 1].first;
      }
      if (seq[i].second <= seq[i - 1].second) {
        seq[i].second = seq[i - 1].second;
      }
    }
    int f = seq[i].first;
    int s = seq[i].second;
    if (last < count(f, s)) {
      last = count(f, s);
      ls = f;
      le = s;
    }
  }
  assert(last == 0 ||
         (last > 0 && ls != -1 && le != -1 && last == count(ls, le)));
  printf("%d\n", last);
  if (last) {
    for (int i = ls; i <= le; i++) {
      putchar(str[i]);
    }
  }
  puts("");
  return 0;
}
