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 java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.Locale;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.InputMismatchException;
import java.util.ArrayDeque;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jacob Jiang
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, InputReader in, OutputWriter out) {
        char[] sequence = in.nextCharArray();
        ArrayDeque<Pair<Integer, Character>> stack = new ArrayDeque<Pair<Integer, Character>>();
        int length = sequence.length;
        boolean[] can = new boolean[length];
        for (int i = 0; i < length; i++) {
            if (sequence[i] == '(' || sequence[i] == '[') {
                stack.push(Pair.makePair(i, sequence[i]));
            } else {
                if (!stack.isEmpty()) {
                    if (open(sequence[i]) == stack.peek().second) {
                        Pair<Integer, Character> pop = stack.pop();
                        can[i] = true;
                        can[pop.first] = true;
                    } else {
                        stack.clear();
                    }
                }
            }
        }
        for (int i = 0; i < length; i++) {
            if (!can[i]) {
                sequence[i] = ' ';
            }
        }
        String[] array = String.valueOf(sequence).trim().split(" +");
        int answerCount = 0;
        String answer = "";
        for (String s : array) {
            int count = Lambda.count(s, new Property<Character>() {
                public boolean can(Character item) {
                    return item == '[';
                }
            });
            if (count > answerCount) {
                answerCount = count;
                answer = s;
            }
        }
        out.println(answerCount);
        out.println(answer);
    }

    private char open(char c) {
        return c == ']' ? '[' : '(';
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 16];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public char[] nextCharArray() {
        return next().toCharArray();
    }

    }

class OutputWriter {
    private PrintWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void println(int x) {
        writer.println(x);
    }

    public void println(String x) {
        writer.println(x);
    }

    public void close() {
        writer.close();
    }

    }

class Pair<A,B> implements Comparable<Pair<A, B>> {
    public final A first;
    public final B second;

    public Pair(A first, B second) {
        this.first = first;
        this.second = second;
    }

    public static <A, B> Pair<A, B> makePair(A first, B second) {
        return new Pair<A, B>(first, second);
    }

    public int compareTo(Pair<A, B> anotherPair) {
        @SuppressWarnings ("unchecked") int result = ((Comparable<A>)first).compareTo(anotherPair.first);
        if (result != 0) {
            return result;
        }
        //noinspection unchecked
        return ((Comparable<B>)second).compareTo(anotherPair.second);
    }


    public String toString() {
        return "(" + first + ", " + second + ")";
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Pair pair = (Pair) o;

        if (first != null ? !first.equals(pair.first) : pair.first != null) return false;
        if (second != null ? !second.equals(pair.second) : pair.second != null) return false;

        return true;
    }

    public int hashCode() {
        int result = first != null ? first.hashCode() : 0;
        result = 31 * result + (second != null ? second.hashCode() : 0);
        return result;
    }
}

class Lambda {

    public static int count(String str, Property<Character> property) {
        int result = 0;
        int len = str.length();
        for (int i = 0; i < len; i++) {
            if (property.can(str.charAt(i))) {
                result++;
            }
        }
        return result;
    }

    }

interface Property<T> {
    boolean can(T item);
}

