2023-12-02 21:35:11 -08:00
|
|
|
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
ios::sync_with_stdio(0);
|
|
|
|
cin.tie(0);
|
|
|
|
|
|
|
|
int ret = 0, id = 0;
|
|
|
|
bool isPossible = true;
|
|
|
|
|
2023-12-03 16:15:40 -08:00
|
|
|
while (!cin.eof()) {
|
|
|
|
switch (cin.get()) {
|
2023-12-02 21:35:11 -08:00
|
|
|
case 'G':
|
2023-12-03 16:15:40 -08:00
|
|
|
cin.ignore(4);
|
2023-12-02 21:35:11 -08:00
|
|
|
cin >> id;
|
|
|
|
break;
|
|
|
|
case ':': case ',': case ';':
|
|
|
|
if (!isPossible)
|
|
|
|
break;
|
2023-12-03 16:15:40 -08:00
|
|
|
cin.ignore(1);
|
2023-12-02 21:35:11 -08:00
|
|
|
int n;
|
|
|
|
cin >> n;
|
2023-12-03 16:15:40 -08:00
|
|
|
cin.ignore(1);
|
|
|
|
switch (cin.get()) {
|
2023-12-02 21:35:11 -08:00
|
|
|
case 'r':
|
|
|
|
if (n > 12)
|
|
|
|
isPossible = false;
|
|
|
|
break;
|
|
|
|
case 'g':
|
|
|
|
if (n > 13)
|
|
|
|
isPossible = false;
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
if (n > 14)
|
|
|
|
isPossible = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
if (isPossible)
|
|
|
|
ret += id;
|
|
|
|
else
|
|
|
|
isPossible = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << ret << '\n';
|
|
|
|
}
|