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;
double EPS = 1e-10;
double EQ(double a, double b) { return abs(a - b) < EPS; }
void fast_stream() {
  cin.tie(0);
  std::ios_base::sync_with_stdio(0);
}
template <class T>
string IntToString(T num) {
  string res;
  stringstream ss;
  ss << num;
  return ss.str();
}
long long StringToInt(string &str) {
  long long res = 0;
  for (int i = 0; i < (int)str.size(); i++) res = (res * 10 + str[i] - '0');
  return res;
}
int match[1000001];
int dp[1000001];
int cnts[1000001];
const int INF = 1 << 30;
int dfs(int pos) {
  if (pos < 0) return INF;
  if (dp[pos] >= 0) return dp[pos];
  if (match[pos] < 0) return INF;
  return dp[pos] = min(match[pos], dfs(match[pos] - 1));
}
int main() {
  memset(match, -1, sizeof(match));
  memset(dp, -1, sizeof(dp));
  fast_stream();
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) cnts[i + 1] = cnts[i] + (s[i] == ']');
  int pos = 0;
  int maxCnt = 0;
  int ofrom, oto;
  stack<pair<char, int> > stk;
  while (1) {
    if (pos == n) break;
    char ch = s[pos];
    if (ch == '(' || ch == '[') {
      if (ch == '(')
        stk.push(pair<char, int>(')', pos));
      else
        stk.push(pair<char, int>(']', pos));
    } else {
      if (stk.size() != 0 && stk.top().first == ch) {
        pair<char, int> p = stk.top();
        stk.pop();
        int to = pos;
        match[pos] = p.second;
        int from = dfs(pos);
        int cnt = cnts[to + 1] - cnts[from];
        if (maxCnt < cnt) {
          maxCnt = cnt;
          ofrom = from;
          oto = to;
        }
      } else {
        while (stk.size()) stk.pop();
      }
    }
    pos++;
  }
  cout << maxCnt << endl;
  if (maxCnt != 0) {
    for (int i = ofrom; i <= oto; i++) cout << s[i];
    cout << endl;
  }
  return 0;
}
