G, C, P = map(int, input().split()) S = input() point = 0 for s in S: if s == "G": if P > 0: point += 3 P -= 1 else: if G > 0: point += 1 G -= 1 elif s == "C": if G > 0: point += 3 G -= 1 else: if C > 0: point += 1 C -= 1 elif s == "P": if C > 0: point += 3 C -= 1 else: if P > 0: point += 1 P -= 1 print(point)