#include #include #include #include using namespace std; int main(void){ int g, c, p; string s; cin >> g >> c >> p >> s; int eg, ec, ep; eg = ec = ep = 0; for(int i = 0; i < s.length(); i++){ if(s[i] == 'G') eg++; if(s[i] == 'C') ec++; if(s[i] == 'P') ep++; } int ans = 0; int temp; temp = min(g, ec); ans += temp * 3; g -= temp; ec -= temp; temp = min(c, ep); ans += temp * 3; c -= temp; ep -= temp; temp = min(p, eg); ans += temp * 3; p -= temp; eg -= temp; temp = min(g, eg); ans += temp; temp = min(c, ec); ans += temp; temp = min(p, ep); ans += temp; cout << ans << endl; return 0; }