#include <iostream>
#include <cstring>

using namespace std;


const int NMAX = 100 + 1;

char s[NMAX], s2[NMAX];

int get_nr(int &i, char *p) {
    int x = 0;
    while ('0' <= p[i] && p[i] <= '9') {
        x = x * 10 + p[i] - '0';
        i++;
    }
    return x;
}

int numar(char *p) {
    int l = strlen(p);

    int nr = 1;
    for (int i = 0; i < l; i++)
        if (p[i] == '[') {
            i++;
            nr = nr * get_nr(i, p);
        }
    return nr;
}

void rezolva() {
    char *p;
    int biti, total = 0;

    if (strcmp(s, "int") == 0) biti = 4;
    else if (strcmp(s, "char") == 0) biti = 1;
    else if (strcmp(s, "short") == 0) biti = 2;
    cin >> s2;
    p = strtok(s2, ",");
    do {
       // cout << p << endl;
        total = total + numar(p) * biti;
       // cout << endl;
        p = strtok(NULL, ",");
    } while (p != NULL);

    cout << total << '\n';
}

int main() {
    while(cin >> s) {
        if (strcmp(s, "unsigned") == 0) cin >> s;
        rezolva();
    }
}