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 maxm = 2e5 + 10;
const int mod = 1e9 + 7;
const long long linf = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
template <typename S, typename T>
inline bool Min(S &a, const T &b) {
  return a > b ? a = b, true : false;
}
template <typename S, typename T>
inline bool Max(S &a, const T &b) {
  return a < b ? a = b, true : false;
}
template <typename S, typename T>
inline void Adm(S &a, const T &b) {
  a = (a + b) % mod;
  if (a < 0) a += mod;
}
template <typename S, typename T>
inline void Mum(S &a, const T &b) {
  a = 1LL * a * b % mod;
}
template <typename T>
inline T Gcd(T a, T b) {
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <typename T>
inline int BitCnt(T x) {
  int cnt = 0;
  while (x) ++cnt, x &= x - 1;
  return cnt;
}
template <typename T>
inline bool IsPri(T x) {
  if (x < 2) return false;
  for (T i = 2; i * i <= x; ++i)
    if (x % i == 0) return false;
  return true;
}
inline long long qpow(long long a, long long n) {
  long long t = 1;
  while (n) {
    if (n & 1) t = t * a % mod;
    a = a * a % mod, n >>= 1;
  }
  return t % mod;
}
void p_bit(long long x) { cout << bitset<32>(x) << ':' << x << endl; }
const int maxn = 2e5 + 10;
int f[maxn], g[maxn];
map<char, char> mp;
int main() {
  mp['['] = 1;
  mp[']'] = -1;
  mp['('] = 2;
  mp[')'] = -2;
  string s;
  cin >> s;
  s = " " + s;
  int res = 0;
  int r = 0;
  int len = 0;
  for (int i = 2; i < s.size(); i++) {
    int x = mp[s[i]], y = mp[s[i - 1]];
    if (x < 0) {
      if (x == -y) {
        f[i] = f[i - 2] + 2;
        if (x == -1)
          g[i] = g[i - 2] + 1;
        else
          g[i] = g[i - 2];
      } else if (y < 0) {
        int xx = f[i - 1];
        if (mp[s[i - xx - 1]] == -x) {
          f[i] = f[i - xx - 2] + f[i - 1] + 2;
          if (x == -1)
            g[i] = g[i - xx - 2] + g[i - 1] + 1;
          else
            g[i] = g[i - xx - 2] + g[i - 1];
        }
      }
    }
    if (res < g[i]) {
      res = g[i];
      len = f[i];
      r = i;
    }
  }
  int l = r - len + 1;
  printf("%d\n", res);
  for (int i = l; i <= r; i++) cout << s[i];
  return 0;
}
