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 java.util.*;

public class Main {

    private static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {

        String S = in.next();
        int left = -1;
        int right = -1;

        char [] c = S.toCharArray();
        int count = 0;

        for (int i = 0; i < c.length; i++) {
            if(c[i]== '[') {
                left = i;
                break;
            }
        }
        if(left == -1) System.out.println(-1);
        else {
            for (int i = c.length - 1; i >= 0; i--) {
                if (c[i] == ']') {
                    right = i;
                    break;
                }
            }
            if (right <= left) {
                System.out.println(-1);
            } else {

                int leftS = 0;
                int rightS = 0;
                for (int i = left + 1; i < right; i++) {
                    if (c[i] == ':') {
                        leftS = i;
                        break;
                    }
                }
                for (int i = right - 1; i > left; i--) {
                    if (c[i] == ':') {
                        rightS = i;
                        break;
                    }
                }
                if (rightS <= leftS) System.out.println(-1);
                else {

                    for (int i = leftS + 1; i < rightS; i++) {
                        if (c[i] != '|') count++;
                    }

                    int ans = (right - left + 1) - (leftS - left - 1) - (right - rightS - 1) - count;
                    System.out.println(ans);
                }
            }
        }
    }
    public String getHint(String secret, String guess) {
        int a = 0;
        int b = 0;
        char [] s = secret.toCharArray();
        char [] g = guess.toCharArray();
        HashSet<Integer> indexes = new HashSet<>();
        for (int i = 0; i < s.length; i++) {
            if(s[i]==g[i]) {
                indexes.add(i);
                a++;
            }
        }
        HashMap<Character,Integer> sMap = new HashMap<>();
        HashMap<Character,Integer> gMap = new HashMap<>();
        for (int i = 0; i < s.length; i++) {
            if(!indexes.contains(i)) {
                Integer value = sMap.get(s[i]);
                sMap.put(s[i], value == null ? 1 : ++value);
            }
        }
        for (int i = 0; i < g.length; i++) {
            if(!indexes.contains(i)) {
                Integer value = gMap.get(g[i]);
                gMap.put(g[i], value == null ? 1 : ++value);
            }
        }

        for (Map.Entry<Character,Integer> m : sMap.entrySet()) {
            char key = m.getKey();
            if(gMap.containsKey(key)) {
                b+=Math.min(m.getValue(),gMap.get(key));
            }
        }

        return a+"A"+b+"B";
    }

    private static String formNewString(HashSet<Character> set) {
        Iterator<Character> it = set.iterator();
        StringBuilder sb = new StringBuilder();
        while (it.hasNext()) {
            sb.append(it.next());
        }
        return sb.toString();
    }

    public int minDistance(String word1, String word2) {
        int max = Integer.MIN_VALUE;
        if(word1.length()>word2.length()) {
            for (int i = 0; i < word1.length(); i++) {
                for (int j = i+1; j < word1.length(); j++) {
                    String temp = word1.substring(i,j);
                    if(word2.contains(temp)) {
                        int l = word1.length() - temp.length() + word2.length() - temp.length();
                        max = Math.max(max,l);
                    }
                }
            }
            return max;
        }
        else {
            for (int i = 0; i < word2.length(); i++) {
                for (int j = i+1; j < word2.length(); j++) {
                    String temp = word2.substring(i,j);
                    if(word1.contains(temp)) {
                        int l = word2.length() - temp.length() + word1.length() - temp.length();
                        max = Math.max(max,l);
                    }
                }
            }
        }
        return 0;
    }

    public boolean hasGroupsSizeX(int[] deck) {
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i = 0; i < deck.length; i++) {
            Integer value = map.get(deck[i]);
            map.put(deck[i], value == null ? 1 : ++value);
        }
        int gcd = 0;
        for (Map.Entry<Integer,Integer> m:map.entrySet()) {
            gcd = gcd(gcd,m.getValue());
        }
        return gcd > 1;
    }
    private static int gcd(int a,int b) {
        return b==0 ? a : gcd(b,a%b);
    }


    static boolean isSh(int n) {
        HashSet<Integer> set = new HashSet<>();
        while (n>0) {
            int k = n%10;
            if(k!= 3 && k!=5 && k!=7) return false;
            set.add(k);
            n/=10;
        }
        return set.size() == 3;
    }
    static int equalStacks(int[] h1, int[] h2, int[] h3) {
        int sum1 = sumOfArray(h1,0);
        int sum2 = sumOfArray(h2,0);
        int sum3 = sumOfArray(h3,0);

        if(sum1==sum2 && sum2==sum3) return sum1;

        int index = 0;

        while (sum1!=sum2 && sum2!=sum3) {

        }

        return 0;
    }

    static int sumOfArray(int [] a,int index) {
        int sum = 0;
        for (int i = index; i < a.length; i++) {
            sum+=a[i];
        }
        return sum;
    }

    public boolean checkInclusion(String s1, String s2) {
        int [] mainFreq = frequency(s1);
        int length = s1.length();
        for (int i = 0; i <=s2.length() - length; i++) {
            String temp = s2.substring(i,length+i);
            int [] freq = frequency(temp);
            boolean check = checkFrequencies(mainFreq,freq);
            if(check) return true;
        }
        return false;
    }

    public List<Integer> findAnagrams(String s, String p) {
        int [] mainFreq = frequency(p);
        int length = p.length();

        List<Integer> indexes = new ArrayList<>();

        for (int i = 0; i <=s.length()-length; i++) {
            String temp = s.substring(i,length+1);
            int [] freq = frequency(temp);
            if(checkFrequencies(freq,mainFreq)) indexes.add(i);
        }
        return indexes;
    }
    private static boolean checkFrequencies(int [] freqA, int [] freqB) {
        for (int i = 0; i < freqA.length; i++) {
            if(freqA[i]!=freqB[i]) return false;
        }
        return true;
    }

    private static int [] frequency(String s) {
        int [] freq = new int[26];
        for (char c:s.toCharArray()) {
            freq[c-'a']++;
        }
        return freq;
    }
    static int lowerBound(int [] a, int target) {
        int lo = 0;
        int hi = a.length - 1;
        int ans = -1;

        while (lo<=hi) {
            int med = hi - (hi-lo)/2;
            if(target == a[med]){
                ans = med;
                hi = med - 1;
            }
            else if(target < a[med])  hi = med - 1;
            else lo = med + 1;
        }
        return ans;
    }

    static int upperBound(int [] a, int target) {
        int lo = 0;
        int hi = a.length - 1;
        while (lo<=hi) {
            int med = hi-(hi-lo)/2;
            if(target>=a[med]) lo = med + 1;
            else hi = med - 1;
        }
        return hi;
    }
    static boolean isPrime(int n) {
        if(n<=2) return false;
        for (int i = 2; i*i <=n ; i++) {
            if(n%i==0) return  false;
        }
        return  true;
    }
    static int [] readAnArray(int n) {
        int [] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        return  a;
    }
}