#include <cstdio>
#include <cstring>

using namespace std;
char vect[1000];
int ind,i;

inline void nume()
{
    while(vect[ind]>='a' && vect[ind]<='z') ++ind;
}

int q()
{
    int nr=0;
    while(vect[ind]>='0' && vect[ind]<='9')
    {
        ++ind;
        nr=nr*10+vect[ind-1]-'0';
    }
    return nr;
}

inline int solve()
{
     int x,nr,s=0;ind=0;
     if(vect[0]=='u') ind+=9;

     if(vect[ind]=='c') {ind+=5;x=1;}
     else if(vect[ind]=='i') {ind+=4;x=4;}
     else if(vect[ind]=='s') {ind+=6;x=2;}

     while(1<2)
     {
         nume();nr=1;
         while(vect[ind]=='[')
         {
             ++ind;
             nr=nr*q();
             ++ind;
         }
         ++ind;s+=nr;
         if(ind>=strlen(vect))
         return s*x;
     }
}

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

    gets(vect);

    do
    {
        printf("%d\n",solve());
        gets(vect);
    }
    while(!feof(stdin));

    return 0;
}