#Created on 2015/03/16 [G, C, P] = map(int, input().split()) S = list(input()) ans = 0 for i in range(len(S)) : if S[i] == 'G' and P > 0 : ans += 3 P -= 1 S[i] = '' if S[i] == 'C' and G > 0 : ans += 3 G -= 1 S[i] = '' if S[i] == 'P' and C > 0 : ans += 3 C -= 1 S[i] = '' for s in S : if s == 'G' and G > 0 : ans += 1 G -= 1 if s == 'C' and C > 0 : ans += 1 C -= 1 if s == 'P' and P > 0 : ans += 1 P -= 1 print(ans)