import java.util.Scanner;

/**
 * Created by Radu on 3/12/2015.
 */
public class prog {
    public static void main(String[] args) {
        int size = 0;
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            String type[] = line.split(" ");
            if (type[0].equals("char") || type[1].equals("char")) {
                size = 1;
            } else if (type[0].equals("short") || type[1].equals("short")) {
                size = 2;
            } else if (type[0].equals("int") || type[1].equals("int")) {
                size = 4;
            }
            String vars = type[0].equals("unsigned") ? type[2] : type[1];
            String[] variables = vars.split(",");
            int ans = 0;
            for (int i = 0; i < variables.length; i++) {
                if (!variables[i].contains("[")) {
                    ans += size;
                } else {
                    int values = 1;
                    String[] dim = variables[i].split("\\[");
                    for (int j = 1; j < dim.length; j++) {
                        dim[j] = dim[j].substring(0, dim[j].length() - 1);
                        values *= Integer.valueOf(dim[j]);
                    }
                    ans+=values*size;
                }
            }
            System.out.println(ans);
        }
    }
}