# Read input G, C, P = map(int, input().split()) S = input().strip() # Count opponent's moves cnt_G = S.count('G') cnt_C = S.count('C') cnt_P = S.count('P') # Calculate maximum wins for each type a = min(cnt_G, P) b = min(cnt_C, G) c = min(cnt_P, C) # Remaining opponent's moves after wins rem_G = cnt_G - a rem_C = cnt_C - b rem_P = cnt_P - c # Remaining moves for yuki yg_rem = G - b yc_rem = C - c yp_rem = P - a # Calculate maximum draws draw_G = min(rem_G, yg_rem) draw_C = min(rem_C, yc_rem) draw_P = min(rem_P, yp_rem) # Total score total_score = 3 * (a + b + c) + (draw_G + draw_C + draw_P) print(total_score)