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) ans += min(G0, G1) G0, G1 = G0-min(G0, G1), G1-min(G0, G1) ans += min(C0, C1) C0, C1 = C0-min(C0, C1), C1-min(C0, C1) ans += min(P0, P1) P0, P1 = P0-min(P0, P1), P1-min(P0, P1) print(ans)