#include <fstream>
#include <cstring>
#include <cctype>
#include <iostream>

#define f cin
#define g cout

using namespace std;

int n , i , x ,total , tip , crt;

char s[200];

int main()
{
    //ifstream f("pp.in");
    //ofstream g("pp.out");

    while (f >> s)
    {
        if (strcmp(s , "char") == 0) tip = 1;
        else if (strcmp(s , "int") == 0) tip = 4;
        else if (strcmp(s , "short") == 0) tip = 2;
        else
        {
            f >> s;
            if (strcmp(s , "char") == 0) tip = 1;
        else if (strcmp(s , "int") == 0) tip = 4;
        else if (strcmp(s , "short") == 0) tip = 2;

        }

        f >> (s+1);
        n = strlen(s+1);
        s[n+1] = ',';
        i = 1;

        total = 0;

        while (true)
        {
            crt = 1;
            while (s[i] != ',')
            {
                x = 0;
                while (!isdigit(s[i]) && s[i] != ',') i++;
                while (isdigit(s[i])) {x = x * 10 + s[i] - '0'; i++;}
                if (x) crt *= x;
            }

            total += crt * tip;

            if (i == n + 1) break;
            i++;
        }

        g << total << '\n';


    }



    return 0;
}