#include using namespace std; typedef long long ll; typedef vector VI; typedef vector VVI; typedef vector VL; typedef vector VVL; typedef pair PII; #define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define MOD 1000000007 #define INF (1LL<<25) //33554432 #define PI 3.14159265359 #define EPS 1e-12 //#define int ll signed main(void) { int g, c, p, gg = 0, cc = 0, pp = 0; string s; cin >> g >> c >> p >> s; REP(i, s.size()) { if(s[i] == 'G') gg++; else if(s[i] == 'C') cc++; else if(s[i] == 'P') pp++; } int ret = 0; ret += 3*min(g, cc); ret += 3*min(c, pp); ret += 3*min(p, gg); g -= min(g, cc); cc -= min(g, cc); c -= min(c, pp); pp -= min(c, pp); p -= min(p, gg); gg -= min(p, gg); ret += min(g, gg); ret += min(c, cc); ret += min(p, pp); cout << ret << endl; return 0; }