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 INF = 1 << 28;
const long long LINF = 1ll << 61;
string s;
int dp[100111];
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
bool can[100111], vis[100111];
stack<pair<char, int> > q;
vector<pair<int, int> > v;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    dp[i] = ((i == 0) ? 0 : dp[i - 1]);
    if (s[i] == '[') dp[i]++;
    if (s[i] == '(' || s[i] == '[') {
      q.push(make_pair(s[i], i));
    } else {
      if (!q.empty() && (s[i] == ')' && q.top().first == '(' ||
                         s[i] == ']' && q.top().first == '[')) {
        v.push_back(make_pair(q.top().second, i));
        q.pop();
      } else {
        while (!q.empty()) q.pop();
      }
    }
  }
  for (int i = 0; i < v.size(); i++) {
    if (i + 1 != v.size() && v[i].first >= v[i + 1].first &&
        v[i].second <= v[i + 1].second)
      can[i] = 0;
    else
      can[i] = 1;
  }
  for (int i = 0; i < v.size(); i++) {
    if (can[i]) {
      for (int j = v[i].first; j <= v[i].second; j++) vis[j] = 1;
    }
  }
  int ans = 0, l = -1, r = -1;
  for (int i = 0; i < s.size(); i++) {
    int cnt = 0;
    while (i < s.size() && vis[i] == 1) {
      cnt++;
      i++;
    }
    if (dp[i - 1] - dp[i - cnt - 1] > ans)
      l = i - cnt, r = i - 1, ans = dp[r] - dp[l - 1];
  }
  if (l == -1)
    cout << "0" << endl;
  else {
    cout << ans << endl;
    for (int i = l; i <= r; i++) cout << s[i];
    cout << endl;
  }
  return 0;
}
