import sys input=lambda: sys.stdin.readline().rstrip() g,c,p=map(int,input().split()) S=input() ans=0 gs,cs,ps=0,0,0 for s in S: if s=="G": gs+=1 elif s=="C": cs+=1 else: ps+=1 if gs>0 and p>0: w=min(gs,p) gs-=w p-=w ans+=3*w if cs>0 and g>0: w=min(cs,g) cs-=w g-=w ans+=3*w if ps>0 and c>0: w=min(ps,c) ps-=w c-=w ans+=3*w print(ans+min(gs,g)+min(cs,c)+min(ps,p))