#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,n) FOR(i,0,n) #define ALL(v) (v).begin(),(v).end() template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } typedef unsigned long long ull; typedef long long ll; typedef pair pii; typedef pair pll; typedef pair P; const ll INF = 1ll<<60; const ll MOD = 1000000007; const double EPS = 1e-10; int g[2], c[2], p[2]; int main() { cin >> g[0] >> c[0] >> p[0]; string s; cin >> s; REP(i, s.size()) { if (s[i] == 'G') g[1]++; if (s[i] == 'C') c[1]++; if (s[i] == 'P') p[1]++; } int ans = 0; int tmp = min(g[0], c[1]); ans += 3 * tmp; g[0] -= tmp; c[1] -= tmp; tmp = min(c[0], p[1]); ans += 3 * tmp; c[0] -= tmp; p[1] -= tmp; tmp = min(p[0], g[1]); ans += 3 * tmp; p[0] -= tmp; g[1] -= tmp; ans += min(g[0], g[1]) + min(c[0], c[1]) + min(p[0], p[1]); cout << ans << endl; return 0; }