//#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

ifstream cin("test.in");
ofstream cout("test.out");

int i,tip,x,sum;
char s[200];

int nr()
{
    int sol=0;
    while(s[i] >= '0' && s[i] <= '9')
    {
        sol =sol*10 + (s[i]-'0');
        ++i;
    }
    ++i;
    return sol;

}

int main()
{
    while(cin.getline(s,200))
    {
        i=0;tip=0;
        if(s[0] == 'u') strcpy(s,s+9);
        if (s[0] == 'c')
        {
            tip = 1;
            i = 5;
        }
        if (s[0] == 'i')
        {
            tip = 4;
            i = 4;
        }
        if (s[0] == 's')
        {
            tip=2;
            i = 6;
        }
        sum = 0;
        while(i < strlen(s))
        {
            while(s[i] != ',' && s[i] != '[') ++i;
            x=1;
            if (s[i] == '[')
            {
                while (s[i] == '[')
                {
                    ++i;
                    x *= nr();
                }
            }
            ++i;
            sum += x*tip;
        }
        cout<<sum<<"\n";
    }
    return 0;
}