#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <cctype>

using namespace std;

char sir[105];

int main()
{
    while (1) {
        cin.get(sir + 1, 105);

        stringstream ss("");
        if (cin.eof())
            break;

        cin.get();

        ss.str(sir + 1);

        string x;
        ss >> x;

        if (x == "unsigned")
            ss >> x;

        int sz = 0;
        if (x == "char")
            sz = 1;
        else if (x == "short")
            sz = 2;
        else
            sz = 4;

        int ans = 0;

        char ch;
        int curent_mat = 1;
        int curent_nr = 0;

        while (1) {
            ss >> ch;

            if (ss.eof())
                break;

            if (ch == ',') {
                ans += curent_mat;
                curent_mat = 1;
                curent_nr = 0;
            }
            else if (isdigit(ch)) {
                curent_nr *= 10;
                curent_nr += (ch - '0');
            }
            else if (ch == ']') {
                curent_mat *= curent_nr;
                curent_nr = 0;
            }
        }

        if (curent_mat)
            ans += curent_mat;

        cout << ans * sz << '\n';
    }
    return 0;
}