/**
 * Created by IntelliJ IDEA.
 * User: o_220
 * Date: 28.10.2009
 * Time: 17:28:12
 * To change this template use File | Settings | File Templates.
 */ import java.util.*;
    import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        Scanner s= new Scanner(new File("smile.in"));
        PrintWriter p= new PrintWriter (new File("smile.out"));
        int [] in = new int [4];
        Arrays.fill (in, 0);
        String s1 = s.nextLine();
        int L1 = s1.length();
        s1 = 'a' + s1 +'a' + ';' + 'a';
        int sum = 0;
        for (int i=1; i < L1+4; i++) {
            if ((s1.charAt(i)==';' || s1.charAt(i)==':') && (s1.charAt(i+1)!=';' || s1.charAt(i+1)!=':') &&
            (s1.charAt(i-1)!=';' || s1.charAt(i-1)!=':')){
                Arrays.fill (in, 0);
                in[0]=1;
            }

            if (in[0]==1){
              /*  if (s1.charAt(i)=='-' ){
                    in[1]=1;
                } */
                if (s1.charAt(i+1)!='(' || s1.charAt(i+1)!=')' || s1.charAt(i+1)!='[' || s1.charAt(i+1)!=']' || s1.charAt(i+1)!='-'){
                    Arrays.fill (in, 0);
                }
                if (s1.charAt(i)=='(' || s1.charAt(i)==')' || s1.charAt(i)=='[' || s1.charAt(i)==']'){
                    in[0]=0;
                    sum++;
                    Arrays.fill (in, 0);
                    /*if ((s1.charAt(i+1)=='(' || s1.charAt(i+1)==')' || s1.charAt(i+1)=='[' || s1.charAt(i+1)==']') &&
                    (s1.charAt(i+1)!=s1.charAt(i))) {
                        Arrays.fill (in, 0);
                    } else {
                        sum++;
                        Arrays.fill (in, 0);
                    }*/

                }
            }
        }
        p.println(sum);
        s.close();
        p.close();
    }
}
