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
/*
Keep solving problems.
*/

import java.util.*;
import java.io.*;

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000 * 1000 * 1000 + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "YES";
    private static final String no = "NO";

    void solve() throws IOException {
        char[] arr = nextString().toCharArray();
        int n = arr.length;
        Stack<Integer> stack = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (arr[i] == '(' || arr[i] == '[') {
                stack.push(i);
            }
            else {
                if (stack.isEmpty()) {
                    stack.push(i);
                }
                else {
                    char top = arr[stack.peek()];
                    if (isMatch(top, arr[i])) {
                        stack.pop();
                    }
                    else {
                        stack.push(i);
                    }
                }
            }
        }

        List<Integer> idx = new ArrayList<>();
        while (!stack.isEmpty()) {
            idx.add(stack.pop());
        }
        Collections.reverse(idx);
        List<Integer> start = new ArrayList<>();
        List<Integer> end = new ArrayList<>();
        int sz = idx.size();
        if (sz > 0) {
            int first = idx.get(0);
            if (first != 0) {
                start.add(0);
                end.add(first - 1);
            }
            int last = idx.get(sz - 1);
            if (last != n - 1) {
                start.add(last + 1);
                end.add(n - 1);
            }
        }
        else {
            start.add(0);
            end.add(n - 1);
        }

        for (int i = 0; i < sz - 1; i++) {
            int first = idx.get(i);
            int second = idx.get(i + 1);
            if (first < second - 1) {
                start.add(first + 1);
                end.add(second - 1);
            }
        }

        int res = 0;
        int idx1 = -1;
        int idx2 = -1;
        for (int i = 0; i < start.size(); i++) {
            int cnt = 0;
            for (int j = start.get(i); j <= end.get(i); j++) {
                if (arr[j] == '[') {
                    cnt++;
                }
            }
            if (res < cnt) {
                res = cnt;
                idx1 = start.get(i);
                idx2 = end.get(i);
            }
        }

        if (res == 0) {
            outln(res);
            outln("");
            return;
        }

        outln(res);
        for (int i = idx1; i <= idx2; i++) {
            out(arr[i]);
        }
    }

    boolean isMatch(char c1, char c2) {
        return (c1 == '(' && c2 == ')') || (c1 == '[' && c2 == ']');
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    int gcd(int a, int b) {
        while(a != 0 && b != 0) {
            int c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}

