G, C, P = map(int, input().split()) S = input() ans = 0 atode = "" for i in range(len(S)): if S[i] == "G" and P > 0: ans += 3 P -= 1 elif S[i] == "C" and G > 0: ans += 3 G -= 1 elif S[i] == "P" and C > 0: ans += 3 C -= 1 else: atode += S[i] for i in range(len(atode)): if atode[i] == "G" and G > 0: ans += 1 G -= 1 if atode[i] == "C" and C > 0: ans += 1 C -= 1 if atode[i] == "P" and P > 0: ans += 1 P -= 1 print(ans)