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;
char st[100100];
int pos[100100], ans, last, L, R = -1;
vector<pair<int, int> > r;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < int(s.size()); i++) {
    if (s[i] == '(' || s[i] == '[')
      st[++last] = s[i], pos[last] = i;
    else {
      char c = (s[i] == ')' ? '(' : '[');
      if (!last || c != st[last])
        last = 0;
      else
        r.push_back(make_pair(pos[last--], i));
    }
  }
  if (!r.empty()) {
    sort(r.begin(), r.end());
    int end = r[0].second, square = 0, start = r[0].first;
    for (int i = r[0].first; i <= r[0].second; i++) square += s[i] == '[';
    if (square > ans) ans = square, L = start, R = end;
    for (int i = 1; i <= int(r.size()) - 1; i++)
      if (r[i].second > end) {
        int cnt = 0;
        for (int j = r[i].first; j <= r[i].second; j++) cnt += s[j] == '[';
        if (r[i].first == end + 1)
          square += cnt;
        else
          start = r[i].first, square = cnt;
        end = r[i].second;
        if (square > ans) ans = square, L = start, R = end;
      }
    if (square > ans) ans = square, L = start, R = end;
  }
  cout << ans << endl;
  for (int i = L; i <= R; i++) cout << s[i];
  cout << endl;
}
