#include #include #include #include #include #include #include using namespace std; typedef long long LL; int main(){ int G, C, P; cin >> G >> C >> P; int og, oc, op; string S; cin >> S; for(int i = 0; i < S.size(); i++){ if(S[i] == 'G') og++; if(S[i] == 'C') oc++; if(S[i] == 'P') op++; } LL ans = 0; int v = min(G, oc); ans += v * 3; G -= v; oc -= v; v = min(C, op); ans += v * 3; C -= v; op -= v; v = min(P, og); ans += v * 3; P -= v; og -= v; ans += min(G, og); ans += min(C, oc); ans += min(P, op); cout << ans << endl; return 0; }