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 MAX = 111111;
int N;
char s[MAX];
int f[MAX];
int sum[MAX];
bool match(int i, int j) {
  if (i < 1 || j < 1) return 0;
  if (s[i - 1] == ')')
    return s[j - 1] == '(';
  else
    return s[j - 1] == '[';
}
int get(int i) { return f[i - 1] < N ? f[i - 1] : i; }
int main() {
  int i, j, k;
  while (cin >> s) {
    N = strlen(s);
    sum[0] = 0;
    for (i = 1; i <= N; ++i) sum[i] = sum[i - 1] + (s[i - 1] == ']');
    memset(f, 127, sizeof f);
    for (i = 2; i <= N; ++i) {
      if (s[i - 1] == '(' || s[i - 1] == '[') continue;
      if (match(i, i - 1)) f[i] = get(i - 1);
      if (f[i - 1] < N && match(i, f[i - 1] - 1))
        f[i] = min(f[i], get(f[i - 1] - 1));
    }
    int ans = 0, ansi;
    for (i = 1; i <= N; ++i)
      if (f[i] < N && sum[i] - sum[f[i] - 1] > ans) {
        ans = sum[i] - sum[f[i] - 1];
        ansi = i;
      }
    printf("%d\n", ans, ansi);
    if (ans > 0) {
      for (i = f[ansi] - 1; i < ansi; ++i) putchar(s[i]);
    }
    puts("");
  }
  return 0;
}
