#include #include #include using namespace std; int main() { int g, c, p; int enemyG = 0, enemyC = 0, enemyP = 0; int score = 0; string s; cin >> g >> c >> p >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'G') { enemyG++; } else if (s[i] == 'C') { enemyC++; } else if(s[i] == 'P') { enemyP++; } } int gWin = min(g, enemyC); int cWin = min(c, enemyP); int pWin = min(p, enemyG); g -= gWin, enemyC -= gWin; c -= cWin, enemyP -= cWin; p -= pWin, enemyG -= pWin; score += 3 * (gWin + cWin + pWin); int gDraw, cDraw, pDraw; gDraw = min(g, enemyG); cDraw = min(c, enemyC); pDraw = min(c, enemyP); score += gDraw + cDraw + pDraw; cout << score << endl; return 0; }