#include <stdio.h> #include <string.h> int main() { char s[101]; int cnt=0,sum=0; while(gets(s)) { if(s[0]=='+') cnt++; else if(s[0]=='-') cnt--; else { int i=0; while(s[i]!=':') i++; sum+=(strlen(s)-i-1)*cnt; } memset(s,0,sizeof(s)); } printf("%d\n",sum); return 0; }