import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class prog { public static void main(final String[] args) { Scanner scan = new Scanner(System.in); while(scan.hasNext()){ int res = 0; String[] line = scan.nextLine().split(" "); String type = line[0]; int next = 1; if(type.equals("unsigned")){ type = line[1]; next = 2; } int typeSize = type.equals("char") ? 1 : (type.equals("short") ? 2 : 4); String[] vars = line[next].split(","); for (int i = 0; i < vars.length; i++) { if(!vars[i].contains("[")){ res += typeSize; } else { Pattern p = Pattern.compile("\\[\\d*\\]"); Matcher m = p.matcher(vars[i]); int localSize = typeSize; while(m.find()){ String group = m.group(); localSize *= Integer.parseInt(group.substring(1, group.length()-1)); } res+=localSize; } } System.out.println(res); } scan.close(); } }