Problem: An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code 091), a colon (ASCII code 058), some (possibly zero) vertical line characters (ASCII code 124), another colon, and a closing bracket (ASCII code 093). The length of the accordion is the number of characters in it.

For example, [::], [:||:] and [:|||:] are accordions having length 4, 6 and 7. (:|:), {:||:}, [:], ]:||:[ are not accordions. 

You are given a string s. You want to transform it into an accordion by removing some (possibly zero) characters from it. Note that you may not insert new characters or reorder existing ones. Is it possible to obtain an accordion by removing characters from s, and if so, what is the maximum possible length of the result?

Input

The only line contains one string s (1 ≤ |s| ≤ 500000). It consists of lowercase Latin letters and characters [, ], : and |.

Output

If it is not possible to obtain an accordion by removing some characters from s, print -1. Otherwise print maximum possible length of the resulting accordion.

Examples

Input


|[a:b:|]


Output


4


Input


|]:[|:]


Output


-1

Solution (in JAVA):

Solution:
import javafx.util.Pair;

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

public class Main {
    class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;
        public FastScanner(InputStream inputStream){
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }
        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()){
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException ignored){}
            }
            return stringTokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    private FastScanner scanner;
    private PrintWriter printer;

    Main(InputStream scanner, PrintWriter printWriter) {
        this.scanner = new FastScanner(scanner);
        this.printer = printWriter;
    }

    int gcd (int a, int b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    boolean isPrime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }

    List<Integer>prostMnoj(int n) {
        ArrayList<Integer> r = new ArrayList<>();
        int p = 2;
        while(n != 1) {
            while(n % p == 0) {
                n /= p;
                r.add(p);
            }
            p++;
            while(!isPrime(p)) {
                p++;
            }
        }
        return r;
    }

    List<Integer>allMnoj(List<Integer>a) {
        ArrayList<Integer>r = new ArrayList<>();
        boolean b[] = new boolean[a.size() + 1];
        while(!b[0]) {
            int i = a.size();
            while(b[i]) {
                i--;
            }
            b[i++] = true;
            while(i<b.length) {
                b[i++] = false;

            }
            int m = 1;
            for (i = 1; i < b.length; i++) {
                if (b[i]) {
                    m*=a.get(i-1);
                }
            }
            r.add(m);
        }
        return r;
    }

    double a(long n) {
        return (180.0 * (n-2)) / n;
    }

    void next (int a[]) {
        for (int i = a.length - 2; i >= 0; i--) {
            if (a[i] < a[i+1]) {
                for (int j = a.length - 1;; j--) {
                    if (a[j] > a[i]) {
                        int t = a[i];
                        a[i] = a[j];
                        a[j] = t;
                        break;
                    }
                }
                for (int j = i + 1; j <= i + ((a.length - 1) - i) / 2; j++) {
                    int t = a[j];
                    int k = (a.length - 1) - (j - (i + 1));
                    a[j] = a[k];
                    a[k] = t;
                }
                break;
            }
        }
    }

    int fact(int n) {
        if (n == 1) return 1;
        return n * fact(n - 1);
    }

    int dfs(List<List<Integer>>g, int v, boolean used[]) {
        if (used[v]) return 0;
        used[v] = true;
        int sum = 1;
        for (int i = 0; i < g.get(v).size(); i++) {
            sum += dfs(g, g.get(v).get(i), used);
        }
        return sum;
    }

    int find(List<List<Integer>>g, int v, int x, boolean used[]) {
        if (used[v]) return -1;
        used[v] = true;
        if (g.get(v).contains(x)) return v;
        for (int i = 0; i < g.get(v).size(); i++) {
            int res = find(g, g.get(v).get(i), x, used);
            if (res != -1) return res;
        }
        return -1;
    }

    int dp[] = new int[101];
    {
        Arrays.fill(dp, -1);
    }

    int[] ms(int n) {
        int dp[] = new int[n + 1];
        int tp[] = new int[n + 1];
        dp[1] = 0;
        tp[1] = 1;
        for (int i = 2; i <= n; i++) {
            int t = i - 1;
            dp[i] = dp[i - 1];
            if (i % 2 == 0 && dp[i / 2] < dp[i]) {
                dp[i] = dp[i / 2];
                t = i / 2;
            }
            if (i % 3 == 0 && dp[i / 3] < dp[i]) {
                dp[i] = dp[i / 3];
                t = i / 3;
            }
            dp[i]++;
            tp[i] = t;
        }
        printer.println(dp[n]);
        int t = n;
        StringBuilder s = new StringBuilder();
        while (t != 1) {
            s.insert(0, t);
            s.insert(0, " ");
            t = tp[t];
        }
        s.insert(0, "1");
        printer.println(s);
        return dp;
    }

    double gg(List<List<Integer>>g, boolean used[], int v) {
        List<Integer> gv = g.get(v);
        used[v] = true;
        if (gv.isEmpty()) return 0;
        if (gv.size() == 1 && used[gv.get(0)]) {
            return 0;
        }
        int k = 0;
        double sum = 0;
        for (int i = 0; i < gv.size(); i++) {
            if (!used[gv.get(i)]) {
                sum += gg(g, used, gv.get(i));
                k++;
            }
        }
        return sum / k + 1;
    }

    long fib(long n)
    {
        if (n < 1) return 0;
        long a = 0;
        long b = 1;
        for (int i = 2; i <= n; i++) {
            long t = a + b;
            a = b;
            b = t;
        }
        return b;
    }

    void run() {
        String s = scanner.next();
        int start = s.indexOf(91);
        int start2 = s.indexOf(58, start + 1);
        int end2 = s.lastIndexOf(93);
        int end = s.lastIndexOf(58, end2 - 1);
        if (!(start == -1 || start2 == -1 || end == -1 || end2 == -1) && start < start2 && start2 < end && end < end2) {
            int d = start + (start2 - start - 1) + (end2 - end - 1) + (s.length() - end2 - 1);
            for (int i = start2 + 1; i < end; i++) {
                if (s.charAt(i) != 124) {
                    d++;
                }
            }
            //|[a:b:|]]
            //printer.println(start + " " + start2 + " " + end + " " + end2);
            printer.println(s.length() - d);
        }
        else {
            printer.println(-1);
        }
        printer.flush();
        printer.close();
    }

    public static void main(String [] args) {
        long start = System.currentTimeMillis();
        new Main(System.in, new PrintWriter(System.out)).run();
        long finish = System.currentTimeMillis();
        System.err.println(finish - start + "ms");
    }
}