#include <iostream>
#include <fstream>
#include <string>
#include <map>
#define LL long long

using namespace std;

map <string, int> m;

int main(){
	string s;
	LL d, res, val;
	//freopen("input.txt", "r", stdin);
	m["char"] = 1;
	m["short"] = 2;
	m["int"] = 4;
	while(!cin.eof()){
		cin >> s;
		while(s == "unsigned")
			cin >> s;
		d = m[s];
		res = 0;
		val = 1;
		cin >> s;
		s += ",";
		for(int i = 0; i < s.size(); ++i){
			if(isalpha(s[i])){
				val = 1;
				continue;
			}
			if(s[i] == ','){
				res += val;
				continue;
			}
			if(s[i] == '['){
				++i;
				LL nr = 0;
				while(s[i] >= '0' && s[i] <= '9'){
					nr = nr * 10 + s[i] - '0';
					++i;
				}
				val *= nr;
			}
		}
		cout << res * d << '\n';
	}
	return 0;
}