#include #include #include using namespace std; int main() { int yuki[3]; cin >> yuki[0] >> yuki[1] >> yuki[2]; string s; cin >> s; int comp[3]; comp[0] = count(s.begin(), s.end(), 'G'); comp[1] = count(s.begin(), s.end(), 'C'); comp[2] = count(s.begin(), s.end(), 'P'); int point = 0; int newYuki[3], newComp[3]; for (int i = 0; i < 3; ++i) { int count = min(yuki[i], comp[(i + 1) % 3]); point += count * 3; newYuki[i] = yuki[i] - count; newComp[(i + 1) % 3] = comp[(i + 1) % 3] - count; } for (int i = 0; i < 3; ++i) { int count = min(newYuki[i], newComp[i]); point += count; } cout << point << endl; return 0; }