//Problem a from mingcoding2015Round3 //"We are drowning in information and starved for knowledge." #include #include #include #include #include #include #include using namespace std; #define int64 long long const int inf = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); char txt[500]; while (cin.getline(txt, 500)) { int itr = 0; int rez = 0, exp = 0; if (txt[0] == 'u') { itr += 8; } while (txt[itr] == ' ') ++itr; if (txt[itr] == 'c') { exp = 1; } else if (txt[itr] == 'i') { exp = 4; } else { exp = 2; } while (txt[itr] != ' ') ++itr; while (itr < int(strlen(txt))) { int m = 1; bool ok = false; while (itr < int(strlen(txt)) and txt[itr] != '[' and txt[itr] != ',') ++itr; while (txt[itr] == '[') { int aux = 0; ++itr; while (itr < int(strlen(txt)) and txt[itr] != ']' and txt[itr] != ',') { aux *= 10; aux += txt[itr] - '0'; ++itr; } itr++; m *= aux; ok = true; } rez += m; if (ok == false and txt[itr] != ',') { break; } if (txt[itr] == ',') { ++itr; } } cout << rez * exp; } return 0; }