#include int main(void){ int i,j,k; int total = 0; int hand[4] = {0}; char s[310]; scanf("%d %d %d", &hand[0], &hand[1], &hand[2]); scanf("%s", s); for(i=0;i<3;i++){ // 0 win, 1 even, 2 lose for(j=0;j<3;j++){ // 0 G, 1 C, 2 P for(k=0;s[k] != '\0';k++){ if(i == 0){ if(hand[j] != 0){ if(j==0 && s[k] == 'C'){ hand[j]--; s[k] = '-'; total += 3; }else if(j==1 && s[k] == 'P'){ hand[j]--; s[k] = '-'; total += 3; }else if(j==2 && s[k] == 'G'){ hand[j]--; s[k] = '-'; total += 3; } } }else if(i == 1){ if(hand[j] != 0){ if(j==0 && s[k] == 'G'){ hand[j]--; s[k] = '-'; total += 1; }else if(j==1 && s[k] == 'C'){ hand[j]--; s[k] = '-'; total += 1; }else if(j==2 && s[k] == 'P'){ hand[j]--; s[k] = '-'; total += 1; } } } } } } printf("%d\n", total); return 0; }