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.
# f = open("data.txt", "r")
# get_input = f.readline
get_input = input

m_br = ("[", "]")
s_br = ("(", ")")
s = get_input().strip()
buffer = []
candidate = []
max_candidate_idx = -1
max_candidate = 0

def add_candidate(candidate, in_tuple):
    start, end, num = in_tuple
    while len(candidate) > 0 and (start < candidate[-1][0] or start - 1 == candidate[-1][1]):
        last_start, _, last_num = candidate.pop(-1)
        start = min(last_start, start)
        num += last_num

    candidate.append((start, end, num))
    if num > max_candidate:
        max_candidate_idx = len(candidate) - 1


for idx, br in enumerate(s):
    if len(buffer) == 0:
        buffer.append((br,idx))
        continue
    
    if (buffer[-1][0], br) == m_br:
        last = buffer.pop(-1)
        add_candidate(candidate, (last[1], idx, 1))
    
    elif (buffer[-1][0], br) == s_br:
        last = buffer.pop(-1)
        add_candidate(candidate, (last[1], idx, 0))
    else:
        buffer.append((br,idx))

if max_candidate > 0:
    res_start, res_end, res_num = candidate[max_candidate_idx]
    print(res_num)
    print(s[res_start:res_end + 1])
else:
    print(0)
    print()


# f.close()

