#include <cstdio>


char v[105];

char aux[105];

int p=0;

void get_string(char a[])
{
    while(v[p]>='a' && v[p]<='z')
    {
        a[++a[0]]=v[p];
        p++;
    }
}

int get_int()
{
    p++;

    int rez=0;

    while(v[p]>='0' && v[p]<'9')
    {
        rez=rez*10+v[p]-'0';
        p++;
    }

    p++;

    return rez;
}

void mergem()
{
    p=1;
    get_string(aux);

    if(aux[1]=='u')
    {
        p++;
        get_string(aux);
    }

    int tip;

    if(aux[1]=='c')
        tip=1;
    if(aux[1]=='i')
        tip=4;
    if(aux[1]=='s')
        tip=2;

    p++;

    int act,rez=0;

    while(v[p]!=0)
    {
        get_string(aux);
        act=1;
        while(v[p]=='[')
            act*=get_int();
        p++;

        rez+=act;
    }

    printf("%d\n",rez*tip);

}

int main()
{
  //  freopen("data.in","r",stdin);
  //  freopen("data.out","w",stdout);

    while(gets(v+1))
        mergem();

    return 0;
}