#define w l[i] main(n,i){char o[9],m[99],l[9];while(gets(l)){if(l[2]=='x')o[*l]=l[9],m[*l]=l[11]-48;else{for(i=strlen(l);i--;)w>47&w<58?n=w-48:w>96?n+=o[w]==43?m[w]:o[w]==45?-m[w]:n*(m[w]-1):0;printf("%d\n",n);}}}