import java.util.Scanner; public class program { public static void main(String[] args) { Scanner s = new Scanner(System.in); while (s.hasNextLine()) { String line = s.nextLine().trim(); String[] words = line.split(" "); String type, vars; int size = 0, dim = 0; if (words[0].equals("unsigned")) { type = words[1]; vars = words[2]; } else { type = words[0]; vars = words[1]; } if (type.equals("char")) size = 1; else if (type.equals("short")) size = 2; else if (type.equals("int")) size = 4; String[] names = vars.split(","); for (int i = 0; i < names.length; i++) if (!names[i].contains("[")) dim += size; else { String[] strAux = names[i].split("\\[|\\]"); int k = 1; for (int j = 1; j < strAux.length; j++) if (!strAux[j].equals("")) k *= Integer.parseInt(strAux[j]); dim += k * size; } System.out.println(dim); } s.close(); } }