#include <iostream> #include <cstdlib> #include <cstdio> #include <string> #include <cstring> #include <cmath> #include <cctype> #include <algorithm> #include <sstream> #include <vector> #include <map> #include <set> #include <queue> #include <stack> #include <bitset> #include <iterator> using namespace std; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; #define INF 1e9 #define ll long long #define ull unsigned long long const int MAXN = 27; int main() { //freopen("C:\\Users\\Sonia\\Documents\\mindCoding.ro\\in.txt", "r", stdin); int n, dim, cnt, dimBr, res; string line, type; char ch; map<string, int> val; val["char"] = 1; val["short"] = 2; val["int"] = 4; val["char"] = 1; while(getline(cin, line)) { istringstream ins(line); dim = 0; cnt = 0; res = 0; ins >> type; if(type == "unsigned") ins >> type; while(ins.get(ch)) { if(ch == ',') { cnt++; } else if(ch == '[') { dimBr = 1; while(ch == '[') { dim++; ins >> n; dimBr *= n; ins>>ch;//] ins >> ch } res += (val[type] * dimBr); } } if(ch == ']') cnt--; res += (val[type] * (cnt + 1)); cout << res << endl; } return 0; }