#include #include #define MAX 300 int main(void) { int point = 0, G,C,P,count,i; char S[MAX]; scanf("%d%d%d",&G,&C,&P); scanf("%s",S); count = G+C+P; for (i = 0; i < count; i++) { if (S[i] == 'G') { if (P > 0) { P--; point += 3; } } else if (S[i] == 'C') { if (G > 0) { G--; point += 3; } } else if (S[i] == 'P') { if (C > 0) { C--; point += 3; } } } for (i = 0; i < count; i++) { if (S[i] == 'G') { if (G > 0) { G--; point++; } } else if (S[i] == 'C') { if (C > 0) { C--; point++; } } else if (S[i] == 'P') { if (P > 0) { P--; point++; } } } printf("%d\n",point); return (0); }