#include <bits/stdc++.h>   using namespace std;   int main() {     char c[101];     int count = 0;     int sum = 0;     while (cin.getline(c, 101)) {       if (c[0] ==  + ) {         count++;         continue;       }       if (c[0] ==  - ) {         count--;         continue;       }       int x = 0;       for (; c[x] !=  : ; x++) {       }       sum += (strlen(c) - (x + 1)) * count;     }     cout << sum;   }   