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
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

s = ri()
sta = []

l,r = -1,-2
lis = []
for i in range(len(s)):
    if s[i] == '(':
        sta.append(['(', i])
    elif s[i] == '[': 
        sta.append(['[', i])
    elif s[i] == ')':
        if len(sta) == 0 or sta[-1][0] != '(':
            sta = []
        else:
            temp = sta.pop()
            lis.append([temp[1], i])
    elif s[i] == ']':
        if len(sta) == 0 or sta[-1][0] != '[':
            sta = []
        else:
            temp = sta.pop()
            lis.append([temp[1], i])

lis.sort(key = lambda x : (x[0], -x[1]))
cur = []
totcnt  =0
cnt = 0
# print(lis)
for i in range(len(lis)):
    if len(cur) == 0:
        cur = lis[i][:]
        if s[lis[i][0]] == '[':
            cnt+=1
    elif cur[0] <= lis[i][0] and lis[i][1] <= cur[1]:
        if s[lis[i][0]] == '[':
            cnt+=1
    else:
        if lis[i][0] == cur[1]+1:
            cur[1] = lis[i][1]
            if s[lis[i][0]] == '[':
                cnt+=1
        else:
            if cnt > totcnt:
                l,r = cur[0],cur[1]
                totcnt = cnt
            cur = lis[i][:]
            cnt = 0
            if s[lis[i][0]] == '[':
                cnt+=1
if cnt > totcnt:
    l,r = cur[0],cur[1]


if l == -1:
    print(0)
else:
    cnt =0 
    for i in range(l, r+1):
        if s[i] == '[':
            cnt+=1
    print(cnt)
    print(s[l:r+1])