#include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int main() { int G, C, P; int g = 0 , c = 0 , p = 0; string s; cin >> G >> C >> P >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'G')g++; if (s[i] == 'C')c++; if (s[i] == 'P')p++; } ll ans = 0; if (G >= c) { ans += c * 3; G -= c; c = 0; } else { ans += G * 3; c -= G; G = 0; } if (C >= p) { ans += p * 3; C -= p; p = 0; } else { ans += C * 3; p -= C; C = 0; } if (P >= g) { ans += g * 3; P -= g; g = 0; } else { ans += P * 3; g -= P; P = 0; } if (G != 0 && g != 0) { if (G == g)ans += g; } if (P != 0 && p != 0) if (P == p)ans += p; if (C != 0 & c != 0) if (C == c)ans += c; cout << ans << endl; return 0; }