#include int times; bool cif(char c){ return '0'<=c&&c<='9'; } int main(){ //freopen("decl.in","r",stdin); //freopen("decl.out","w",stdout); bool f=true; while(f){ f=false; char c='a'; char cc='a'; int res=0; int phase=0; int curr=0; int nr=0; while(true){ int x=scanf("%c",&c); if(c=='\0'||c=='\n'){ res+=curr; break; } if(x<=0) break; f=true; if(phase==0) if(c=='c'){ times=1; phase=1; } else if(c=='s'){ times=2; phase=1; } else if(c=='i'){ times=4; phase=1; } else phase=-1; else if(phase==-1){ if(c==' ') phase=0; } else if(phase==1){ if(cc==' '||cc==','){ res+=curr; curr=1; } else if(cif(c)) nr=nr*10+c-'0'; else if(c==']'){ curr*=nr; nr=0; } } cc=c; } if(!f) break; printf("%I64d\n",(long long)res*times); } return 0; }