G, C, P = map(int, input().split(" ")) S = input() g = S.count("G") c = S.count("C") p = S.count("P") win = 0 if G == c and C == p and P == g: win = (G+C+P)*3 else: if G >= c: win += c G -= c c = 0 else: win += G c -= G G = 0 if P >= g: win += g P -= g g = 0 else: win += P g -= P P = 0 if C >= p: win += p C -= p p = 0 else: win += C p -= C C = 0 win *= 3 if G >= g: win += g G -= g g = 0 else: win += G g -= G G = 0 if P >= p: win += p P -= p p = 0 else: win += P p -= P P = 0 if C >= c: win += c C -= c c = 0 else: win += C c -= C C = 0 print(win)