#include <bits/stdc++.h>

using namespace std;

map<string, int> TypeToBytes;

char Declaration[105];

int main() {
    //freopen("test.in", "r", stdin);
    while (!cin.eof()) {
        int total_memory = 0;
        int partial_memory = 0;
        cin.getline(Declaration, 105, '\n');

        int len = strlen(Declaration);
        int typebytes = 0;
        int offset = 0;

        if (!strncmp("unsigned ", Declaration + offset, 9))
            offset += 9;
        if (!strncmp("int ", Declaration + offset, 4))
            offset += 4, typebytes = 4;
        else if (!strncmp("short ", Declaration + offset, 4))
            offset += 6, typebytes = 2;
        else if (!strncmp("char ", Declaration + offset, 4))
            offset += 5, typebytes = 1;

        partial_memory = typebytes;
        int dimension = 0;
        bool in_bracket = false;
        for (int i = offset; i < len; i++) {
            if (Declaration[i] == '[') {
                in_bracket = true;
            }
            else if (Declaration[i] == ']') {
                partial_memory *= dimension;
                in_bracket = false;
                dimension = 0;
            }
            else if (in_bracket) {
                dimension = dimension * 10 + Declaration[i] - '0';
            }
            else if (Declaration[i] == ',') {
                total_memory += partial_memory;
                partial_memory = typebytes;
            }
        }
        total_memory += partial_memory;

        cout << total_memory << '\n';
    }



    return 0;
}