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>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
string toStr(T x) {
  stringstream st;
  st << x;
  string s;
  st >> s;
  return s;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 100100;
const int OSN = (1 << 17) - 1;
string s;
pair<int, int> p[MAXN];
map<pair<int, int>, vector<int> > v;
int n, bal[MAXN], ta[2 * OSN + 100], tb[2 * OSN + 100], bad[MAXN];
int getSum(int *d, int l, int r) {
  int ans = d[r];
  if (l > 0) ans -= d[l - 1];
  return ans;
}
void update(int *t, int v, int value) {
  v += OSN;
  t[v] = value;
  while (v > 0) {
    v = (v - 1) >> 1;
    t[v] = min(t[2 * v + 1], t[2 * v + 2]);
  }
}
int getMin(int *t, int v, int l, int r, int ll, int rr) {
  if (l > rr || ll > r || ll > rr) return INF;
  if (ll <= l && r <= rr) return t[v];
  int mid = (l + r) >> 1;
  return min(getMin(t, 2 * v + 1, l, mid, ll, rr),
             getMin(t, 2 * v + 2, mid + 1, r, ll, rr));
}
int main() {
  cin >> s;
  n = (int)s.size();
  s += "#";
  int a = 0, b = 0;
  memset(ta, 60, sizeof ta);
  memset(tb, 60, sizeof tb);
  vector<char> c;
  for (int i = 0; i < (int)(n + 1); i++) {
    p[i] = make_pair(a, b);
    if (i != 0) {
      bal[i] = bal[i - 1];
      bad[i] = bad[i - 1];
    }
    if (s[i] == '(') {
      a++;
      c.push_back(s[i]);
    }
    if (s[i] == '[') {
      b++;
      c.push_back(s[i]);
    }
    if (s[i] == ')') {
      a--;
      if (c.empty() || c.back() != '(') bad[i]++;
      if (!c.empty()) c.pop_back();
    }
    if (s[i] == ']') {
      b--;
      if (c.empty() || c.back() != '[') bad[i]++;
      if (!c.empty()) c.pop_back();
    }
    v[p[i]].push_back(i);
    update(ta, i, p[i].first);
    update(tb, i, p[i].second);
    if (s[i] == '[') bal[i]++;
  }
  int ans = 0, l = 0, r = 0;
  for (map<pair<int, int>, vector<int> >::iterator i = v.begin(); i != v.end();
       i++) {
    if (i->first.first < -INF / 2) continue;
    vector<int> &pos = i->second;
    int k = 0;
    for (int j = 0; j < (int)(pos.size()); j++) {
      k = max(k, j + 1);
      while (k < (int)pos.size() &&
             getMin(ta, 0, 0, OSN, pos[j], pos[k]) >= i->first.first &&
             getMin(tb, 0, 0, OSN, pos[j], pos[k]) >= i->first.second &&
             getSum(bad, pos[j], pos[k - 1] - 1) == 0)
        k++;
      if (k - 1 > j &&
          getMin(ta, 0, 0, OSN, pos[j], pos[k - 1]) >= i->first.first &&
          getMin(tb, 0, 0, OSN, pos[j], pos[k - 1]) >= i->first.second &&
          getSum(bad, pos[j], pos[k - 1] - 1) == 0) {
        int L = pos[j], R = pos[k - 1], cur = getSum(bal, L, R - 1);
        if (cur > ans) {
          ans = cur;
          l = L;
          r = R;
        }
      }
    }
  }
  cout << ans << endl;
  cout << s.substr(l, r - l) << endl;
  return 0;
}
