a,b,c=map(int,input().split()) s=input() ca,cb,cc=0,0,0 for i in range(len(s)): if s[i]=='G':ca+=1 if s[i]=='C':cb+=1 if s[i]=='P':cc+=1 out=0 t=min(a,cb) out+=t a-=t cb-=t t=min(b,cc) out+=t b-=t cc-=t t=min(c,ca) out+=t c-=t ca-=t print(out+min(a,ca)+min(b,cb)+min(c,cc))