Bracket Sequence

bracket sequence is a string, containing only characters “(“, “)”, “[” and “]”.

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.

substring s[l… r] (1 ≤ l ≤ r ≤ |s|) of string s = s 1 s 2… s |s| (where |s| is the length of string s) is the string s l s l + 1… s rThe 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

Solution:

{$R-,S-,Q-,I-,O+}
var
s: ansistring;
sp: array [0..400010] of longint;
good: array [0..400010] of boolean;
st: array [0..400010] of char;
n,i,j,cur,k,ans,ax,ay,e: longint;
begin
readln(s);
n:=length(s);
for i:=1 to n do good[i]:=False;
e:=0;
for i:=1 to n do
if (s[i] = '(') or (s[i] = '[') then
begin
inc(e);
st[e]:=s[i];
sp[e]:=i;
end else
if e = 0 then continue else
if (st[e] = '(') and (s[i] = ')') or (st[e] = '[') and (s[i] = ']') then
begin
good[i]:=True;
good[sp[e]]:=True;
dec(e);
end
else e:=0;
good[n+1]:=False;
ans:=-1; ax:=0; ay:=0;
i:=1;
while i <= n do
  begin
    if not good[i] then
    begin
      inc(i);
      continue;
    end;
    j:=i;
    while (j <= n) and (good[j]) do inc(j);
    cur:=0;
    for k:=i to j-1 do
      if s[k] = '[' then inc(cur);
    if cur > ans then
begin
ans:=cur;
ax:=i;
ay:=j-1;
end;
i:=j;
end;
if ans = -1 then writeln(0) else
begin
writeln(ans);
for i:=ax to ay do write(s[i]);
writeln;
end;
end.