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 gcd(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long binpow(long long a, long long b) {
  if (b == 0) return 1;
  long long res = binpow(a, b / 2) % 1000000007;
  if (b % 2)
    return (((long long)res * (long long)res % 1000000007) * (long long)a) %
           1000000007;
  else
    return ((long long)res * (long long)res) % 1000000007;
}
void solve() {
  string s;
  cin >> s;
  int n = s.length();
  int dp[n][2];
  memset(dp, 0, sizeof(dp));
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == ']' || s[i] == ')') continue;
    int t = dp[i + 1][0];
    if (s[i] == '(') {
      if (i + t + 1 < n && s[i + t + 1] == ')') {
        dp[i][0] = dp[i + 1][0] + 2 + ((i + t + 2 < n) ? dp[i + t + 2][0] : 0);
        dp[i][1] = dp[i + 1][1] + ((i + t + 2 < n) ? dp[i + t + 2][1] : 0);
      }
    }
    if (s[i] == '[') {
      if (i + t + 1 < n && s[i + t + 1] == ']') {
        dp[i][0] = dp[i + 1][0] + 2 + ((i + t + 2 < n) ? dp[i + t + 2][0] : 0);
        dp[i][1] = dp[i + 1][1] + 1 + ((i + t + 2 < n) ? dp[i + t + 2][1] : 0);
      }
    }
  }
  int id = -1, mx = 0;
  for (int i = 0; i < n; i++) {
    if (dp[i][1] > mx) {
      mx = dp[i][1];
      id = i;
    }
  }
  cout << mx << endl;
  if (mx == 0) return;
  for (int i = id; i < id + dp[id][0]; i++) {
    cout << s[i];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int T = 1;
  while (T--) {
    solve();
  }
}
