#include #include #include using namespace std; int main() { freopen("a.in", "r", stdin); freopen("a.out", "w", stdout); char type[20], name[20],c; int n,p,s=0,nr,exp; while (cin >> type) { if (type[0] == 'u'&&type[1] == 'n') cin >> type; if (type[0] == 'c') n = 1; else if (type[0] == 's') n = 2; else n = 4; p = 1; s = 0; nr = 0; exp = 1; while (scanf("%c",&c)) { if (c != ',') { p = 1; if (c == '[') { while (c != ','&&c != '\n') { if (c == '[') { nr = 0; exp = 1; } while (scanf("%c", &c) && c >= '0'&&c <= '9') { nr = nr*exp + (int)(c - '0'); exp *= 10; } if (c == ']') p = p*nr; } s += p; if (c == '\n') break; } } else if (c != ' ') s++; if (c == '\n'){ s++; break; } } cout << s*n << "\n"; } }