g,c,p=map(int,input().split()) s=input() dic={'G': p ,'C':g ,'P':c} dic2={'G':dic['C'],'C':dic['P'],'P':dic['G']} f=[1]*len(s) cnt=0 for i in range(len(s)): if dic[s[i]] > 0: dic[s[i]] -= 1 cnt+=3 f[i] = 0 for i in range(len(s)): if dic2[s[i]] > 0 and f[i] > 0: dic2[s[i]] -= 1 cnt+=1 print(cnt)