#include <iostream> #include <fstream> #include <algorithm> #include <stdio.h> #include <string> #include <math.h> #include <vector> #include <queue> #define pb push_back #define lm 510 using namespace std; string s,l,a; int nr,res,n; string read() { string aux; int i=0; while(l[i]!=' ') { aux+=l[i]; i++; } l.erase(0,i+1); return aux; } int main() { //freopen("cmlsc.in","r",stdin); while(getline(cin,l)) { s=read(); if(s=="unsigned") s=read(); if(s=="int") nr=4; else if(s=="char") nr=1; else if(s=="short") nr=2; bool ok=false; n=0; res=0; for(int i=0; i<l.size(); i++) { if(l[i]==']') { int h=n; n=0; for(int j=0; j<a.size(); j++) { n*=10; n+=a[j]-'0'; } a.clear(); if(h) n*=h; ok=false; } if(ok) { a+=l[i]; } if(l[i]=='[') ok=true; if(l[i]==',') { if(n==0) n=1; res+=nr*n; n=0; } } if(n==0) n=1; res+=nr*n; cout<<res<<'\n'; } return 0; }