#include #define REP(i,n) for(int i = 0; i < (int)(n); ++i) using namespace std; int main() { int G, C, P; cin >> G >> C >> P; string S; cin >> S; int g = 0, c = 0, p = 0; REP(i,S.size()){ if (S[i] == 'G') g++; if (S[i] == 'C') c++; if (S[i] == 'P') p++; } int ans = 0; if(P>=g){ ans += 3*g; P -= g; g = 0; }else{ ans += 3*P; g -= P; P = 0; } if(C>=p){ ans += 3*p; C -= p; p = 0; }else{ ans += 3*C; p -= C; C = 0; } if(G>=c){ ans += 3*c; G -= c; c = 0; }else{ ans += 3*G; c -= G; G = 0; } ans += min(g,G); ans += min(c,C); ans += min(p,P); cout << ans << endl; return 0; }