#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define dbg(x) (cout<<#x<<" = "<<(x)<<'\n') #ifdef HOME const string inputFile = "input.txt"; const string outputFile = "output.txt"; #else const string problemName = ""; const string inputFile = problemName + ".in"; const string outputFile = problemName + ".out"; #endif typedef long long int lld; typedef pair PII; typedef pair PIL; typedef pair PLI; typedef pair PLL; const int INF = (1LL << 31) - 1; const lld LINF = (1LL << 62) - 1; const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1}; const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1}; const int MOD = (int)(1e9) + 7; const int NMAX = 100000 + 5; const int MMAX = 100000 + 5; const int KMAX = 100000 + 5; const int PMAX = 100000 + 5; const int LMAX = 100000 + 5; const int VMAX = 100000 + 5; int N; char A[105]; char B[105]; int main() { int i, sol, ans, a; #ifndef ONLINE_JUDGE freopen(inputFile.c_str(), "r", stdin); freopen(outputFile.c_str(), "w", stdout); #endif for(; scanf("%s", A) + 1;) { if(A[0] == 'u') scanf("%s", A); scanf("%s", B); N = strlen(B); sol = 0; ans = 1; for(i = 0; i < N; i++) { if(B[i] == ',') { sol += ans; ans = 1; } else if(B[i] == '[') { a = 0; i++; while(B[i] != ']') { a = a * 10 + B[i] - '0'; i++; } ans *= a; } } sol += ans; if(A[0] == 'c') a = 1; if(A[0] == 's') a = 2; if(A[0] == 'i') a = 4; printf("%d\n", sol * a); } return 0; }