#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main(){ int g, c, p, pts = 0, og = 0, oc = 0, op = 0; string s; vector me(3), opp(3); cin >> me[0] >> me[1] >> me[2] >> s; for (int i = 0; i < s.size(); i++){ if (s[i] == 'G') opp[2]++; else if (s[i] == 'C') opp[0]++; else opp[1]++; } for (int i = 0; i < 3; i++){ int tmp = min(me[i], opp[i]); pts += tmp*3; me[i] -= tmp; opp[i] -= tmp; } for (int i = 0; i < 3; i++){ if (me[i]) pts += min(me[i], opp[(3+i-1)%3]); } cout << pts << endl; }