#include using namespace std; int C[3]; main(){ int M[3]; scanf("%d%d%d",&M[0],&M[1],&M[2]); char S[51]; scanf("%s",S); for(int i = 0;i < strlen(S);i++){ if(S[i]=='G')C[0]++; else if(S[i]=='C')C[1]++; else C[2]++; } int point = 0,n; for(int i = 0;i < 3;i++){ n = min(M[i],C[(i+1)%3]); M[i] -= n;C[(i+1)%3] -= n;point += n*3; } for(int i = 0;i < 3;i++){ n = min(M[i],C[i]); M[i] -= n;C[i] -= n;point += n; } printf("%d\n",point); }