from collections import Counter def main(): G, C, P = map(int, input().split()) S = input() score = 0 for other_hand in S: match other_hand: case "G": if P > 0: score += 3 P -= 1 elif G > 0: score += 1 G -= 1 else: C -= 1 case "C": if G > 0: score += 3 G -= 1 elif C > 0: score += 1 C -= 1 else: P -= 1 case "P": if C > 0: score += 3 C -= 1 elif P > 0: score += 1 P -= 1 else: G -= 1 print(score) if __name__ == "__main__": main()