#include #include using namespace std; int getNumber(string s) { int x = 0; for (int i = 0; i < s.size(); i++) { x = x * 10 + s[i] - '0'; } return x; } int main() { string s; while (1) { getline(cin, s); if (s.size() == 0) break; string st; int type = 0; int temp = 1; int result = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '[' && (st[0] < '0' || st[0] > '9')) { temp = 1; while (s[i] == '[') { int x = 0; i++; while (s[i] >= '0' && s[i] <= '9' && i < s.size()) { x = x * 10 + s[i] - '0'; i++; } if (s[i] == ']') temp *= x, i++; } i--; result += temp * type; st = ""; } else { if (s[i] == ' ' || s[i] == ',') { if (type == 0) { if (st == "char") type = 1; else if (st == "short") type = 2; else if (st == "int") type = 4; else if (st == "unsigned") st = ""; } else { if (st.size() > 0) if ((st[0] < '0' || st[0] > '9')) result += type; } st = ""; } else st.push_back(s[i]); } } if (st.size() > 0) if ((st[0] < '0' || st[0] > '9')) result += type; cout << result << '\n'; } return 0; }