# -*- coding: utf-8 -*- G,C,P = map(int,raw_input().strip().split()) S = raw_input().strip() point = 0 for i in range(len(S)): if S[i]=="G": if P>0: P-=1;point+=3 elif G>0: G-=1;point+=1 else: C-=1 if S[i]=="C": if G>0: G-=1;point+=3 elif C>0: C-=1;point+=1 else: P-=1 if S[i]=="P": if C>0: C-=1;point+=3 elif P>0: P-=1;point+=1 else: G-=1 print point