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