#include #include #include using namespace std; int u[3], e[3]; int main(void){ cin >> u[0] >> u[1] >> u[2]; string s; cin >> s; for (char c : s){ if (c == 'G') e[0]++; if (c == 'C') e[1]++; if (c == 'P') e[2]++; } int ans = 0; for (int i = 0; i < 3; i++){ int k = min(u[i], e[(i + 1) % 3]); ans += 3 * k; u[i] -= k; e[(i + 1) % 3] -= k; } for (int i = 0; i < 3; i++){ ans += min(u[i], e[i]); } cout << ans << endl; return 0; }