G0, C0, P0 = map(int, input().split()) S = str(input()) G1, C1, P1 = 0, 0, 0 for c in S: if c == 'G': G1 += 1 elif c == 'C': C1 += 1 else: P1 += 1 ans = 0 ans += min(G0, C1)*3 G0, C1 = G0-min(G0, C1), C1-min(G0, C1) ans += min(C0, P1)*3 C0, P1 = C0-min(C0, P1), P1-min(C0, P1) ans += min(P0, G1)*3 P0, G1 = min(P0, G1), G1-min(P0, G1) if C1: if C0 >= C1: C0 -= C1 ans += C1 C1 = 0 else: ans += C0 C1 -= C0 P0 -= C1 C0 = 0 C1 = 0 if P1: if P0 >= P1: P0 -= P1 ans += P1 P1 = 0 else: ans += P0 P1 -= P0 G0 -= P1 P0 = 0 P1 = 0 if G1: if G0 >= G1: G0 -= G1 ans += G1 G1 = 0 else: ans += G0 G1 -= G0 C0 -= G1 G0 = 0 G1 = 0 print(ans)