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;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }
void showvd(vector<double> v) {
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " " << endl;
}
void showvi(vector<int> v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
void showvl(vector<long long> v) {
  for (int i = 0; i < v.size(); i++)
    cout << v[i] << " "
         << " ";
  cout << endl;
}
void showvp(vector<pair<int, int> > v) {
  for (int i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
}
long long fastpower(long long a, long long n, long long p) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = (ans * a) % p;
    a = (a * a) % p;
    n = n >> 1;
  }
  return ans % p;
}
vector<bool> prime(1001, true);
void SOE(int n) {
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void factor(int n, vector<int> &v) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      int z = n / i;
      if (z != i) v.push_back(z);
    }
  }
}
bool chk(char c1, char c2) {
  if (c1 == '(' && c2 == ')') return true;
  if (c1 == '[' && c2 == ']') return true;
  return false;
}
void solve() {
  string v;
  cin >> v;
  vector<pair<int, int> > res;
  stack<int> second;
  for (int i = 0; i < (int)v.size(); i++) {
    if (v[i] == '(' || v[i] == '[')
      second.push(i);
    else if (!second.empty() && chk(v[second.top()], v[i])) {
      int x = second.top();
      second.pop();
      res.push_back(make_pair(x, i));
    } else {
      while (!second.empty()) second.pop();
    }
  }
  sort(begin(res), end(res));
  if (res.size() == 0) {
    cout << "0" << endl << endl;
    return;
  }
  vector<pair<int, int> > arr;
  int l = res[0].first, r = res[0].second;
  for (int i = 1; i < (int)res.size(); i++) {
    if (res[i].first == r + 1) {
      r = res[i].second;
    } else if (res[i].first > r) {
      arr.push_back(make_pair(l, r));
      l = res[i].first;
      r = res[i].second;
    }
  }
  arr.push_back(make_pair(l, r));
  string fin = "";
  int ct_fin = 0;
  for (int i = 0; i < (int)arr.size(); i++) {
    int ct = 0;
    string s1 = v.substr(arr[i].first, arr[i].second - arr[i].first + 1);
    for (int j = 0; j < (int)s1.size(); j++) {
      if (s1[j] == '[') ct++;
    }
    if (ct >= ct_fin) {
      ct_fin = ct;
      fin = s1;
    }
  }
  cout << ct_fin << endl << fin << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
