#coding: utf-8 ##yuki_161 gy,cy,py=map(int,raw_input().split()) s=raw_input() g=s.count('G') c=s.count('C') p=s.count('P') res=(min(gy,c)+min(cy,p)+min(py,g))*3 gr=cr=pr=gyr=cyr=pyr=0 if gy>c: gyr=gy-c if cy>p: cyr=cy-p if py>g: pyr=py-g if g>py: gr=g-py if c>gy: cr=c-gy if p>cy: pr=p-cy if gyr and gr: res+=min(gyr,gr) if cyr and cr: res+=min(cyr,cr) if pyr and pr: res+=min(pyr,pr) print res