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.
s=list(input())
st=[]
a=[0]*len(s)
for i in range(len(s)):
    if s[i]==']':
        if len(st)>0 and st[-1][0]=='[':
            a[st[-1][1]]=i
        else:
            st=[]
    elif s[i]==')':
        if len(st)>0 and st[-1][0]=='(':
            a[st[-1][1]]=i
        else:
            st=[]
    else:
        st.append([s[i],i])

mans=0
ml=0
mr=0



def kkk(s,l,r):
    ans=0
    for i in range(l,r+1):
        if s[i]=='[':
            ans+=1
    return ans
        
i=0
while i<len(s):
    while i<len(s) and a[i]==0: i+=1
    if i<len(s):
        l=i
        r=a[i]
        while r+1<len(s) and a[r+1]>0: r=a[r+1]
        t=kkk(s,l,r)
        if t>mans:
            mans=t
            ml=l
            mr=r
        i=r+1

print(mans)
if mans>0:
    for i in range(ml,mr+1):
        print(s[i],end='')
