#include #include using namespace std; int yukiG, yukiC, yukiP; string S; int tomoG, tomoC, tomoP; void input(istream& in) { in >> yukiG >> yukiC >> yukiP; in >> S; } int resolve() { tomoG = tomoC = tomoP = 0; for (char ch : S) { switch (ch) { case 'G': tomoG++; break; case 'C': tomoC++; break; case 'P': tomoP++; break; } } int score = 0; int tmp; tmp = (yukiG < tomoC) ? yukiG : tomoC; yukiG -= tmp; tomoC -= tmp; score += 3 * tmp; tmp = (yukiC < tomoP) ? yukiC : tomoP; yukiC -= tmp; tomoP -= tmp; score += 3 * tmp; tmp = (yukiP < tomoG) ? yukiP : tomoG; yukiP -= tmp; tomoG -= tmp; score += 3 * tmp; tmp = (yukiG < tomoG) ? yukiG : tomoG; score += tmp; tmp = (yukiC < tomoC) ? yukiC : tomoC; score += tmp; tmp = (yukiP < tomoP) ? yukiP : tomoP; score += tmp; return score; } int main(int argc, char **argv) { input(cin); cout << resolve() << endl; return 0; }