#include <iostream> using namespace std; string tip,vlist,var; int sz,pos; string getvar() { string s=""; while(pos<vlist.size() && vlist[pos]!=',') {s+=vlist[pos];++pos;} ++pos; return s; } int res,i,k,x,nr,j; int main() { while(cin>>tip) { res=0; if(tip=="unsigned") cin>>tip; if(tip=="char") sz=1; else if(tip=="short") sz=2; else sz=4; pos=0; cin>>vlist; while(pos<vlist.size()) { var=getvar(); nr=1; for(i=var.length()-1;i>=0;--i) if(var[i]==']') { x=0; j=i; while(var[j]!='[') --j; for(k=j+1;k<i;++k) x=x*10+var[k]-'0'; nr*=x; i=j+1; } res=res+nr*sz; } cout<<res<<'\n'; } return 0; }