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.
class Element():
    def __init__(self,val):
        self.val=val
        self.next=None
        self.prev=None
class Stack():
    def __init__(self):
        self.last=None
    def push(self,val):
        new_ele = Element(val)
        if self.last is None: self.last=new_ele
        else:
            self.last.next=new_ele
            new_ele.prev=self.last
            self.last=new_ele
    def pop(self):
        last=self.last
        if last is None:return last
        elif last.prev is None:
            self.last=None
            return last.val
        else:
            self.last=last.prev
            self.last.next=None
            return last.val
    def peek(self):
        if self.is_empty() is False:return self.last.val
        else: return None
    def is_empty(self): 
        return self.last is None
    def empty(self):
        self.last=None
def sonN():
    s = input()
    r,k,g,c,x,n,y,d,e=[],0,' ',0,-1,Stack(),0,0,0
    for i in s:
        if i=='(':
            r.append(i)
            n.push(i)
            x+=1
            d+=1
        elif i=='[':
            r.append(i)
            n.push(i)
            x+=1
            y+=1
        elif i==')':
            if n.is_empty() is False and n.peek()is'(':
                r.append(i)
                n.pop()
                x+=1
                e+=1
            else:
                if n.is_empty() is True:
                    if c>k:
                        k=c
                        g=''.join(r)
                else:
                    if c>k:
                        While True:
                            if r[x]==']' or r[x]==')' or x==0:break
                            elif r[x]=='(':
                                r.pop(x)
                                d-=1
                            else:
                                r.pop(x)
                                y-=1
                            x-=1
                        for f in range(max(c-y,e-d)):
                            if r[0]=='(' and e!=d:
                                r.pop(0)
                                d-=1
                            elif r[0]=='[' and c!=y:
                                r.pop(0)
                                y-=1
                        k=c
                        g=''.join(r)
                r=[]
                c=d=e=y=0
                x=-1
                n.empty()
        else:
            if n.is_empty() is False and n.peek() is '[':
                r.append(i)
                n.pop()
                x+=1
                c+=1
            else:
                if n.is_empty() is True:
                    if c>k:
                        k=c
                        g=''.join(r)
                else:
                    if c>k:
                        While True:
                            if r[x]==']' or r[x]==')':break
                            elif r[x]=='(':
                                r.pop(x)
                                d-=1
                            else:
                                r.pop(x)
                                y-=1
                            x-=1
                        for f in range(max(c-y,e-d)):
                            if r[0]=='(' and e!=d:
                                r.pop(0)
                                d-=1
                            elif r[0]=='[' and c!=y:
                                r.pop(0)
                                y-=1
                            k=c
                            g=''.join(r)
                r=[]
                c=d=e=y=0
                x=-1
                n.empty()
    print(k)
    print(g)
def main():
    sonN()
if __name__ == '__main__':
    main()