#include using namespace std; int main() { #ifdef DEBUG std::ifstream in("/home/share/inputf.in"); std::cin.rdbuf(in.rdbuf()); #endif int A[3], B[3] = {0}, C; cin >> A[0] >> A[1] >> A[2]; string S; cin >> S; int ans = 0; for(int i = 0; i < S.length(); i++) { if(S[i] == 'G') B[0]++; if(S[i] == 'C') B[1]++; if(S[i] == 'P') B[2]++; } for(int j = 0; j < 3; j++) { for (int i = 0; i < 3; i++) { int k = (i - j + 4) % 3; C = min(A[i], B[k]); A[i] -= C, B[k] -= C; if(j == 0) ans += C * 3; if(j == 1) ans += C; } } cout << ans << endl; return 0; }