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