import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class prog {


//    public static final Pattern var_def = Pattern.compile("((unsigned){0, 1}) (char | short | int ) (\\,)*");


    private static int  parseVars(String vars) {
//        String commaVars = vars + ",";
        String [] commaParts = vars.split(",");
        int number = 0;
        for (int i = 0; i < commaParts.length; i++) {
            String commaPart = commaParts[i];
            if (commaPart != null) {
                number += countPart(commaPart);
            }
        }
        return number;

    }

    private static int countPart(String part) {
        if (!part.contains("[")) {
            return 1;
        }
        int product = 1;

        int indexFirst = part.indexOf('[', 0);
        while (indexFirst != -1) {
            int indexNext = part.indexOf(']', indexFirst + 1);
            String nrPart = part.substring(indexFirst + 1, indexNext);
            product *= Integer.parseInt(nrPart);
            indexFirst = part.indexOf('[', indexNext);
        }
        return product;


    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


        int nrBytes = 0;
        String line = br.readLine();
        while (line != null) {

            String[] split = line.split(" ");
            String s;
            int poz ;
            if (split.length == 2) {
                s = split[0];
                poz = 1;
            } else {
                s = split[1];
                poz = 2;

            }
            if ("char".equalsIgnoreCase(s)) {
                nrBytes = 1;
            } else if ("short".equalsIgnoreCase(s)) {
                nrBytes = 2;
            } else if ("int".equalsIgnoreCase(s)) {
                nrBytes = 4;
            }
            int i = nrBytes * parseVars(split[poz]);
            System.out.println(i);
            line = br.readLine();
        }


    }



}