#include using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int ret = 0, id = 0, r = 0, g = 0, b = 0; while (!cin.eof()) { switch (cin.get()) { case 'G': cin.ignore(4); cin >> id; break; case ':': case ',': case ';': cin.ignore(1); int n; cin >> n; cin.ignore(1); switch (cin.get()) { case 'r': r = max(n, r); break; case 'g': g = max(n, g); break; case 'b': b = max(n, b); break; } break; case '\n': ret += r * g * b; r = 0; g = 0; b = 0; break; } } cout << ret << '\n'; }