#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; int main() { int g,c,p; cin>>g>>c>>p; string s; cin>>s; int gg,cc,pp; FOR(i,0,s.length()) { if(s[i]=='G') gg++; if(s[i]=='C') cc++; if(s[i]=='P') pp++; } int ans = 0; int mn = min(g, cc); ans += mn * 3; g -= mn; cc -= mn; mn = min(c, pp); ans += mn * 3; c -= mn; pp -= mn; mn = min(p, gg); ans += mn * 3; p -= mn; gg -= mn; // aiko mn = min(g, gg); ans += mn; g -= mn; gg -= mn; mn = min(c, cc); ans += mn; c -= mn; cc -= mn; mn = min(p, pp); ans += mn; p -= mn; pp -= mn; printf("%d\n", ans); return 0; }