#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; ans += min(G, oc) * 3; G -= min(G, oc); ans += min(C, op) * 3; C -= min(C, op); ans += min(P, og) * 3; P -= min(P, og); ans += min(G, og); ans += min(C, oc); ans += min(P, op); cout << ans << endl; return 0; }