#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int v, w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { int G, C, P; cin >> G >> C >> P; string S; cin >> S; int g = 0, c = 0, p = 0; for (int i = 0; i < S.length(); i++) { if (S[i] == 'G') g++; if (S[i] == 'C') c++; if (S[i] == 'P') p++; } int k, ans = 0; k = min(G, c); G -= k; c -= k; ans += k * 3; k = min(C, p); C -= k; p -= k; ans += k * 3; k = min(P, g); P -= k; g -= k; ans += k * 3; k = min(G, g); G -= k; g -= k; ans += k; k = min(C, c); C -= k; c -= k; ans += k; k = min(P, p); P -= k; p -= k; ans += k; cout << ans << endl; }