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* = *s*<sub class="lower-index">1</sub>*s*<sub class="lower-index">2</sub>... *s*<sub class="lower-index">|*s*|</sub> (where |*s*| is the length of string *s*) is the string *s*<sub class="lower-index">*l*</sub>*s*<sub class="lower-index">*l* + 1</sub>... *s*<sub class="lower-index">*r*</sub>. 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.
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 10<sup class="upper-index">5</sup> characters.
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FO(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOD(i,a,b) for(int i=a;i>b;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define DEBUG(a) {cerr << #a << ": " << (a) << endl; fflush(stderr); }

using namespace std;

typedef pair<char,int>II;
typedef pair<int,II>PII;
template<class T> T gcd(T a, T b) {T r; while(b!=0) {r=a%b;a=b;b=r;} return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }

const double PI = 2*acos(0.0);
const double eps = 1e-9;
const int infi = 1e9;
const LL Linfi = (LL) 1e18;
#define MOD 1000000007
#define maxn 100005


int n;
int cnt[maxn];
string s;
vector<II> S;

void solve() {
    int n = s.size();
    s = '0' + s;
    cnt[0] = 0;
    FOR(i,1,n) {
        cnt[i] = cnt[i-1] + (s[i] == '[');
    }
    int ans = 0, L = 0, R = 0, st = 1;
    FOR(i,1,n) {
        if(s[i]== '(')
            S.push_back(II(')', i));
        else if(s[i] == '[')
            S.push_back(II(']', i));
        else if(!S.empty()) { // ] )
            if(S.back().first != s[i]) {
                S.clear();
                st = i+1;
            }
            else {
                int tmpL, tmpR = i;
                S.pop_back();

                //cerr << i << " " << s[i] << endl;
                if(S.empty()) tmpL = st;
                else tmpL = S.back().second;
                int numOpen = cnt[tmpR] - cnt[tmpL-1];
                if (numOpen > ans) {
                    ans = numOpen;
                    L = tmpL;
                    R = tmpR;
                }
            }

        }
    }

    cout << ans << endl;
    if(ans > 0) {
        string tmp = s.substr(L, R-L+1);
        cout << tmp << endl;
    }
}

int main() {
	#ifndef ONLINE_JUDGE
    freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    #endif
    cin >> s;
    solve();



    return 0;
}
