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;
long long int binpowmod(long long int a, long long int b, long long int m) {
  a %= m;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long int binpow(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return binpowmod(n, p - 2, p);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, m, n, i, f = 0, j, ans = 0, k, x, r, l;
  string s;
  cin >> s;
  n = s.length();
  vector<pair<long long int, long long int>> v;
  long long int a[n];
  for (i = 0; i < n; ++i) a[i] = -1;
  stack<long long int> s1;
  ans = 0;
  for (i = 0; i < n; ++i) {
    if (s[i] == '(') s1.push(i);
    if (s[i] == ')') {
      if (s1.size() == 0)
        continue;
      else {
        x = s1.top();
        if (s[x] == '(') {
          a[i] = x;
          s1.pop();
        } else {
          while (!s1.empty()) s1.pop();
        }
      }
    }
    if (s[i] == '[') s1.push(i);
    if (s[i] == ']') {
      if (s1.size() == 0)
        continue;
      else {
        x = s1.top();
        if (s[x] == '[') {
          a[i] = x;
          s1.pop();
        } else {
          while (!s1.empty()) s1.pop();
        }
      }
    }
  }
  for (r = n - 1; r > 0; --r) {
    if (a[r] == -1) continue;
    l = a[r];
    while (l > 0) {
      if (a[l - 1] == -1) break;
      l = a[l - 1];
    }
    v.push_back({l, r});
    r = l;
  }
  long long int temp;
  l = -1;
  r = -1;
  ans = 0;
  for (i = 0; i < v.size(); ++i) {
    temp = 0;
    for (j = v[i].first; j < v[i].second; ++j) {
      if (s[j] == '[') temp++;
    }
    if (temp > ans) {
      l = v[i].first;
      r = v[i].second;
      ans = temp;
    }
  }
  cout << ans << endl;
  if (l == -1) {
    cout << "";
    return 0;
  }
  for (i = l; i <= r; ++i) {
    cout << s[i];
  }
  return 0;
}
