#include <iostream>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<set>
#include<stack>
#include<sstream>
using namespace std;

int main()
{
    string s;
    while(getline(cin, s)){
        istringstream in(s);
        string type = s;
        in >> type;
        if(type == "unsigned"){
            string s1;
            in>>type;
        }
        string other;
        in >> other;

        char c;
        int sum = 0;
        int typeCost = 0;
        if(type.substr(0,4) == "char" || type.substr(0,14) == "unsingned char"){
            typeCost = 1;

       // cout  <<other << " " <<  other.length() << endl;
        }else if(type.substr(0,5) == "short" || type.substr(0,15) == "unsigned short"){
            typeCost = 2;

        }else if(type.substr(0,3) == "int" || type.substr(0,13) == "unsigned int"){
            typeCost = 4;

        }
        for(int i = 0; i < other.length(); i++){
            string dim = "";
            //istringstream in1(other);
            bool inDimension = false;
            int dimensions = 1;
            while(i<other.length() && other[i] != ','){
               // cout << other[i] << endl;
                if(other[i] == ']'){
                    inDimension = false;
                    //cout << dim << endl;
                    dimensions = dimensions*atoi(dim.c_str());
                    //cout << dimensions << endl;

                    dim = "";

                }
                else if(inDimension){
                    dim+=other[i];
                    //cout << dim << endl;
                }else if(other[i] == '['){
                    inDimension = true;
                }
                i++;
            }
            sum+=dimensions*typeCost;
            //cout << typeCost << endl;
           // cout <<"s " <<  sum << endl;
        }

        cout << sum << endl;

    }
    return 0;
}