#include int main(void){ int g,c,p,eg=0,ec=0,ep=0,l,i,r = 0; char s[512]; scanf("%d%d%d%s",&g,&c,&p,s); l = g+c+p; for(i = 0;i < l;i++){ if(s[i] == 'G'){eg++;} if(s[i] == 'C'){ec++;} if(s[i] == 'P'){ep++;} } if(eg<=p){r+=(3*eg);p-=eg;eg=0;}else{r+=(3*p);eg-=p;p=0;} if(ec<=g){r+=(3*ec);g-=ec;ec=0;}else{r+=(3*g);ec-=g;g=0;} if(ep<=c){r+=(3*ep);c-=ep;ep=0;}else{r+=(3*c);ep-=c;c=0;} if(eg<=g){r+=eg;}else{r+=g;} if(ec<=c){r+=ec;}else{r+=c;} if(ep<=p){r+=ep;}else{r+=p;} printf("%d\n",r); return 0; }