#include <iostream>
#include <cstring>

using namespace std;

char sir[1001], *va, *typ;
int i, total, nr, rez, V[101], k;

int main()
{
    cin.getline(sir, 1001);
    while (sir[0]!=0)
    {
        typ=strtok(sir, " ,");
        va=strtok(NULL, " ,");
        rez=0;
        while (va!=0)
        {
            total=1;
            for (i=0; i<=strlen(va)-1; i++)
            {
                if (va[i]=='[')
                {
                    nr=0;
                    i++;
                    while (va[i]!=']')
                    {
                        nr=nr*10+va[i]-'0';
                        i++;
                    }
                }
                if (nr>0)
                    total=total*nr;
            }
            rez+=total;
            va=strtok(NULL, " ,");
        }
        if (typ[0]=='i')
            rez*=4;
        if (typ[0]=='s')
            rez*=2;
        V[k]=rez;
        k++;
        cin.getline(sir, 1001);
    }
    for(i=0; i<k; i++)
        cout<<V[i]<<'\n';
    return 0;
}