G, C, P = map(int, input().split()) S = input().rstrip() EG, EC, EP = 0, 0, 0 for s in S: if s == "G": EG += 1 elif s == "C": EC += 1 else: EP += 1 ans = 0 ans += 3 * min(G, EC) if G >= EC: G -= EC EC = 0 else: EC -= G G = 0 ans += 3 * min(C, EP) if C >= EP: C -= EP EP = 0 else: EP -= C C = 0 ans += 3 * min(P, EG) if P >= EG: P -= EG EG = 0 else: EG -= P P = 0 ans += min(G, EG) ans += min(C, EC) ans += min(P, EP) print(ans)