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 main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  vector<int> L(s.size(), -1);
  vector<pair<char, int>> S;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '(') S.push_back({'(', i});
    if (s[i] == '[') S.push_back({'[', i});
    if (s[i] == ')') {
      if (S.empty() || S.back().first != '(')
        S.clear();
      else
        L[i] = S.back().second, S.pop_back();
    }
    if (s[i] == ']') {
      if (S.empty() || S.back().first != '[')
        S.clear();
      else
        L[i] = S.back().second, S.pop_back();
    }
  }
  string best = "";
  int best_cnt = 0;
  vector<string> ats;
  for (int i = s.size() - 1; i >= 0; i--)
    if (L[i] != -1) {
      string x = s.substr(L[i], i - L[i] + 1);
      vector<string> m;
      m.push_back(x);
      i = L[i] - 1;
      while (i >= 0 && L[i] != -1) {
        x = s.substr(L[i], i - L[i] + 1);
        m.push_back(x);
        i = L[i] - 1;
      }
      string z;
      reverse(m.begin(), m.end());
      for (auto& x : m) z += x;
      int cnt = 0;
      for (auto& ch : z)
        if (ch == '[') cnt++;
      if (cnt > best_cnt) best = z, best_cnt = cnt;
    }
  cout << best_cnt << "\n" << best;
}
